android.intent.action.MEDIA_MOUNTED广播无法收到的问题

来源:互联网 发布:深圳人众软件 编辑:程序博客网 时间:2024/06/07 02:25

 只需要增加一条语句就好,   <data android:scheme="file"/>,无该语句,BroadcastReceiver将无法收SD卡插拔广播消息

 

  <intent-filter>

     <action android:name="android.intent.action.MEDIA_MOUNTED"/>

     <action android:name="android.intent.action.MEDIA_EJECT" />

      <data android:scheme="file"/>

 </intent-filter>

 

 

 

data元素XML定义(参见/reference/android/R.styleable.html#AndroidManifestData):

host

mimeType

path

pathPattern

pathPrefix

port

scheme,例如file,http,https等

-------------------------------以上是静态监听,动态监听也是一样,如下------------------------------------------
要在intentFilter中加上这名话。
intentFilter.addDataScheme("file");
阅读全文
0 0