將開發(fā)過(guò)程常用的內(nèi)容段做個(gè)收藏耕拷,下邊資料是關(guān)于Android系統(tǒng)下監(jiān)聽SD卡的插入并讀取內(nèi)容的內(nèi)容。
private final BroadcastReceiver broadcastRec =? new BroadcastReceiver() {
? ? ? ? @Override
? ? ? ? public void onReceive(Context context, Intent intent) {
? ? ? ? ? ? {? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ||intent.getAction().equals("android.intent.action.ACTION_MEDIA_UNMOUNTED")
? ? ? ? ? ? ? ? ? ? ||intent.getAction().equals("android.intent.action.ACTION_MEDIA_BAD_REMOVAL"))
? ? ? ? ? ? {
? ? ? ? ? ? }
? ? ? ? }
? ? };
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");