首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >android intent for sdcard ready

android intent for sdcard ready
EN

Stack Overflow用户
提问于 2010-08-06 00:57:49
回答 1查看 9.1K关注 0票数 18

我有一个使用SD卡上的文件的应用程序,该应用程序在手机启动时运行,很明显,当程序第一次运行时无法访问该文件,因为它在SD卡可用之前开始工作。

有没有广播接收器可以让我知道SD卡准备好了?

更新

简单地总结一下注册意图的答案:

代码语言:javascript
复制
IntentFilter filter = new IntentFilter (Intent.ACTION_MEDIA_MOUNTED); 
filter.addDataScheme("file"); 
registerReceiver(this.mSDInfoReceiver, new IntentFilter(filter));

并创建一个广播接收器来对其作出反应:

代码语言:javascript
复制
private BroadcastReceiver mSDInfoReceiver = new BroadcastReceiver(){
    @Override
    public void onReceive(Context arg0, Intent intent) {
    // Code to react to SD mounted goes here
    }
 }; 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-08-06 01:02:25

Intent上查找ACTION_MEDIA_MOUNTED广播操作

代码语言:javascript
复制
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"
票数 18
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3417161

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档