我創建一個BroadcastReceiver檢測SD卡安裝和卸載 事件的任何廣播事件,但是,我不能在所有接收任何事件: 這裏的AndroidManifest.xml中:Android的廣播接收器無法接收
<receiver android:enabled="true" android:label="SDCardMountReceiver" android:exported="true" android:name="xxx.broadcasts.SDCardBroadcastReceiver">
<intent-filter>
<action android:name="android.content.Intent.ACTION_MEDIA_MOUNTED"></action>
<!-- or <action android:name="android.content.Intent.ACTION_MEDIA_UNMOUNTED" />--></intent-filter>
</receiver>
而且SDCardMountReceiver類:
public class SDCardBroadcastReceiver extends BroadcastReceiver {
public SDCardBroadcastReceiver() {
super();
System.err.println("constructor");
}
public void onReceive(Context context, Intent intent) {
Log.d("SDCardBroadCastReceiver", "receive " + intent.getAction());
System.err.println("jonathan receive " + intent.getAction());
}
}
什麼東西在日誌文件中可疑? – 2009-06-15 17:31:29
我想你需要在Manifest文件中給用戶權限 試試這個
2010-06-17 07:15:30