LoginSignup
0
0

More than 5 years have passed since last update.

Androidで動くBASICでGoogle Driveと連携する

Last updated at Posted at 2017-03-08

BASIC!は、Androidで動くBASIC インタープリタです。詳しくは以下をどうぞ。

BASIC!にはインテントを扱う命令が二つしかなく、Androidで動く言語としては貧弱です。それでもGoogle Driveに連携する方法が見つかったので書いておきます。

1.BASIC!のインテント関連の命令

App.startとApp.broadcastの2つしかありません。今回はApp.startを使いました。命令の詳細はマニュアルをごらんください。

2.コード

とても短いですがさっそくコードです。ポイントは以下

  • grabfile命令でテキストファイルの内容を取得
  • bundleを生成しGoogle drive上のファイル名称とファイルの内容をセット
  • app.startで暗黙的インテント(android.intent.action.SEND)を指定
  • app.startの引数としてmimeやbundleのポインターを指定
REM Start of BASIC! Program

filename$="test.txt"

grabfile datf$,filename$,1

bundle.create bptr
bundle.put bptr,"android.intent.extra.SUBJECT","from basic!"
bundle.put bptr,"android.intent.extra.TEXT",datf$

app.start "android.intent.action.SEND",,,,"text/plain",,bptr

bundle.clear bptr

end

3.まとめ、その他

  • BASIC!のプログラムから暗黙的インテント経由でGoogle Driveに連携可能
  • Google DriveならできるがDropboxだとファイル名称が連携できない
  • 大きなサイズのファイルだとこの方法は無理かも
  • 当然ですがGoogle Driveアプリは事前にインストールが必要です
  • android5.1のタブレットで動作確認しました

以上です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0