List of usage examples for android.content Intent ACTION_MEDIA_REMOVED
String ACTION_MEDIA_REMOVED
To view the source code for android.content Intent ACTION_MEDIA_REMOVED.
Click Source Link
From source file:org.chromium.ChromeSystemStorage.java
private static BackgroundEventHandler<ChromeSystemStorage> createEventHandler() { return new BackgroundEventHandler<ChromeSystemStorage>() { @Override/*from w ww . ja v a 2 s .co m*/ public BackgroundEventInfo mapBroadcast(Context context, Intent intent) { String action = intent.getAction(); if (!(Intent.ACTION_MEDIA_MOUNTED.equals(action) || Intent.ACTION_MEDIA_BAD_REMOVAL.equals(action) || Intent.ACTION_MEDIA_REMOVED.equals(action) || Intent.ACTION_MEDIA_SHARED.equals(action) || Intent.ACTION_MEDIA_UNMOUNTED.equals(action))) { // Ignore any other actions return null; } BackgroundEventInfo event = new BackgroundEventInfo(action); event.getData().putString(DATA_STORAGE_PATH, intent.getDataString()); return event; } @Override public void mapEventToMessage(BackgroundEventInfo event, JSONObject message) throws JSONException { boolean attached = Intent.ACTION_MEDIA_MOUNTED.equals(event.action); // Sanitize the path provided with the event String storagePath = getBaseStoragePath( Uri.parse(event.getData().getString(DATA_STORAGE_PATH)).getPath()); ChromeSystemStorage plugin = getCurrentPlugin(); // The attached/detached events may fire before the client has a chance to call getInfo(). // Thus, must initialize the external storage here (if not already done), to ensure that // unit ids are consistent across calls to getInfo, and subsequent attach/detach events. StorageFile[] directories = plugin.initializeExternalStorageDirectories(); String unitId = plugin.getExternalStorageId(storagePath); StorageFile attachedStorage = null; if (attached) { attachedStorage = plugin.getExternalStorageDirectoryByPath(storagePath, directories); } else { // If the detached event causes initialization, the unit id may not be found // as it won't be reported in the list of directories. We can safely generate // a random id, as the client won't have called getInfo yet. if (unitId == null) { unitId = UUID.randomUUID().toString(); } } message.put("action", attached ? "attached" : "detached"); message.put("id", unitId); if (attached) { JSONObject storageUnit = plugin.buildExternalStorageUnitInfo(attachedStorage); message.put("info", storageUnit); } } }; }
From source file:org.videolan.vlc.gui.tv.browser.BaseTvActivity.java
@Override protected void onResume() { super.onResume(); mIsVisible = true;/*from w ww .j a va 2s . c o m*/ //Handle network connection state IntentFilter networkFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); IntentFilter storageFilter = new IntentFilter(Intent.ACTION_MEDIA_MOUNTED); storageFilter.addAction(Intent.ACTION_MEDIA_REMOVED); storageFilter.addAction(Intent.ACTION_MEDIA_EJECT); storageFilter.addDataScheme("file"); IntentFilter parsingServiceFilter = new IntentFilter(MediaParsingService.ACTION_SERVICE_ENDED); parsingServiceFilter.addAction(MediaParsingService.ACTION_SERVICE_STARTED); mRegistering = true; LocalBroadcastManager.getInstance(this).registerReceiver(mParsingServiceReceiver, parsingServiceFilter); registerReceiver(mExternalDevicesReceiver, storageFilter); registerReceiver(mExternalDevicesReceiver, networkFilter); }
From source file:org.videolan.vlc.gui.DirectoryViewFragment.java
@Override public void onStart() { super.onStart(); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_MEDIA_MOUNTED); filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); filter.addAction(Intent.ACTION_MEDIA_REMOVED); filter.addAction(Intent.ACTION_MEDIA_EJECT); filter.addDataScheme("file"); getActivity().registerReceiver(messageReceiver, filter); }
From source file:org.xwalk.runtime.extension.api.device_capabilities.DeviceCapabilitiesStorage.java
private void registerIntentFilter() { mIntentFilter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL); mIntentFilter.addAction(Intent.ACTION_MEDIA_MOUNTED); mIntentFilter.addAction(Intent.ACTION_MEDIA_REMOVED); mIntentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED); mIntentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED); mIntentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); mIntentFilter.addDataScheme("file"); }
From source file:answer.example.answer.activity.FileChooserActivity.java
/** * Register the external storage BroadcastReceiver. */// w w w . j a va 2 s . co m private void registerStorageListener() { IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_MEDIA_REMOVED); registerReceiver(mStorageListener, filter); }
From source file:org.fourthline.android.feeds.filechooser.FileChooserActivity.java
/** * Register the external storage BroadcastReceiver. *//*from ww w .ja v a 2 s. co m*/ private void registerStorageListener() { IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_MEDIA_REMOVED); registerReceiver(storageListener, filter); }
From source file:com.nadmm.airports.ActivityBase.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDbManager = DatabaseManager.instance(this); mInflater = getLayoutInflater();/*from w w w . jav a2s. com*/ overridePendingTransition(R.anim.fade_in, R.anim.fade_out); mHandler = new Handler(); mFilter = new IntentFilter(); mFilter.addAction(Intent.ACTION_MEDIA_MOUNTED); mFilter.addAction(Intent.ACTION_MEDIA_SHARED); mFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); mFilter.addAction(Intent.ACTION_MEDIA_REMOVED); mFilter.addDataScheme("file"); mExternalStorageReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { externalStorageStatusChanged(); } }; if (Application.sDonationDone == null) { DonateDatabase db = new DonateDatabase(this); Cursor c = db.queryAllDonations(); Application.sDonationDone = c.moveToFirst(); db.close(); } // Enable Google Analytics ((Application) getApplication()).getAnalyticsTracker(); }
From source file:com.loloof64.android.chess_position_manager.MainActivity.java
@Override protected void onResume() { super.onResume(); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_MEDIA_REMOVED); filter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL); filter.addAction(Intent.ACTION_MEDIA_EJECT); filter.addAction(Intent.ACTION_MEDIA_NOFS); filter.addAction(Intent.ACTION_MEDIA_SHARED); filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); registerReceiver(mStorageReceiver, filter); }
From source file:org.arakhne.afc.ui.android.filechooser.FileChooserActivity.java
/** * Register the external storage BroadcastReceiver. *///from ww w .j a va2s.c o m private void registerStorageListener() { IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_MEDIA_REMOVED); registerReceiver(this.storageListener, filter); }
From source file:com.dudu.aios.ui.activity.MainRecordActivity.java
private void registerTFlashCardReceiver() { mTFlashCardReceiver = new TFlashCardReceiver(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_MEDIA_MOUNTED); intentFilter.addAction(Intent.ACTION_MEDIA_REMOVED); intentFilter.addDataScheme("file"); registerReceiver(mTFlashCardReceiver, intentFilter); }