2010-08-05 14 views
18

Ho un'applicazione che utilizza un file sulla scheda SD, l'applicazione viene eseguita all'avvio del telefono ed è diventato evidente che non è possibile accedere al file quando il programma viene eseguito per la prima volta mentre inizia a funzionare prima che la scheda SD sia disponibile.Android intent per sdcard ready

C'è un ricevitore di trasmissione che posso usare per dire quando la scheda SD è pronta?

Aggiornamento

Giusto per riassumere la risposta per registrare l'intento fare:

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

e creare un ricevitore broadcast a reagire ad esso:

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

risposta

18

Lookup ACTION_MEDIA_MOUNTED azione trasmissione su Intent

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" 
Problemi correlati