ste*_*ter 18 android sd-card broadcastreceiver android-intent
我有一个使用SD卡上的文件的应用程序,应用程序在手机启动时运行,并且很明显,当程序首次运行时无法访问该文件,因为它在SD卡可用之前开始工作.
是否有一个广播接收器,我可以用来判断SD卡准备好了吗?
更新
只是为了总结注册意图的答案:
IntentFilter filter = new IntentFilter (Intent.ACTION_MEDIA_MOUNTED);
filter.addDataScheme("file");
registerReceiver(this.mSDInfoReceiver, new IntentFilter(filter));
Run Code Online (Sandbox Code Playgroud)
并创建一个广播接收器来响应它:
private BroadcastReceiver mSDInfoReceiver = new BroadcastReceiver(){
@Override
public void onReceive(Context arg0, Intent intent) {
// Code to react to SD mounted goes here
}
};
Run Code Online (Sandbox Code Playgroud)
Pen*_*m10 18
ACTION_MEDIA_MOUNTED在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"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8957 次 |
| 最近记录: |