版权声明:本文为博主原创文章,未经博主允许不得转载 https://blog.csdn.net/hnlgzb/article/details/88816619
broadcastRec = new SDcardBroadcastReceiver();
IntentFilter intentFilter = new IntentFilter(
Intent.ACTION_MEDIA_MOUNTED);
intentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
intentFilter.addAction(Intent.ACTION_MEDIA_REMOVED);
intentFilter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);
intentFilter.addDataScheme("file");
registerReceiver(broadcastRec, intentFilter);