阅读背景:

Android 监听sdcard插拔广播_Jackchen 的博客

来源:互联网 

一、如果是单个Activity需要监听广播,推荐使用动态广播

        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
        filter.addAction(Intent.ACTION_MEDIA_CHECKING);
        filter.addAction(Intent.ACTION_MEDIA_EJECT);
        filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
        filter.addAction(Intent.ACTION_MEDIA_REMOVED);
        filter.addDataScheme("file"); //必须添加,否则无法监听到SD卡插拔广播
        registerReceiver(mBroadcastReceiver, filter);        Intent



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: