18

SD カード上のファイルを使用するアプリケーションがあり、電話の起動時にアプリケーションが実行されます。SD カードが利用可能になる前にプログラムが動作し始めるため、プログラムを最初に実行したときにファイルにアクセスできないことが明らかになりました。

SD カードの準備ができたことを伝えるために使用できる放送受信機はありますか?

アップデート

インテントを登録するための答えを要約すると、次のようになります。

IntentFilter filter = new IntentFilter (Intent.ACTION_MEDIA_MOUNTED); 
filter.addDataScheme("file"); 
registerReceiver(this.mSDInfoReceiver, new IntentFilter(filter));

それに反応するブロードキャストレシーバーを作成します。

private BroadcastReceiver mSDInfoReceiver = new BroadcastReceiver(){
    @Override
    public void onReceive(Context arg0, Intent intent) {
    // Code to react to SD mounted goes here
    }
 }; 
4

1 に答える 1

18

IntentのルックアップACTION_MEDIA_MOUNTEDブロードキャスト アクション

public static final String ACTION_MEDIA_MOUNTED

Since: API Level 1
Broadcast Action: External media is present and mounted at its mount point. The path to the mount point for the removed media is contained in the Intent.mData field. The Intent contains an extra with name "read-only" and Boolean value to indicate if the media was mounted read only.
Constant Value: "android.intent.action.MEDIA_MOUNTED"
于 2010-08-05T17:02:25.153 に答える