Java Code Examples for android.content.Intent#ACTION_MEDIA_REMOVED
The following examples show how to use
android.content.Intent#ACTION_MEDIA_REMOVED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MediaStatusReceiver.java From edx-app-android with Apache License 2.0 | 5 votes |
@Override public void handleReceive(Context context, Intent intent) { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { return; } prefManager = new PrefManager(context, PrefManager.Pref.USER_PREF); final String username = loginPrefs.getUsername(); final String hashedUsername = (username != null) ? Sha1Util.SHA1(username) : null; final String sdCardPath = intent.getDataString().replace("file://", ""); final String action = intent.getAction(); if (action != null) { boolean sdCardAvailable = false; switch (action) { case Intent.ACTION_MEDIA_REMOVED: case Intent.ACTION_MEDIA_UNMOUNTED: sdCardAvailable = false; handleSDCardUnmounted(hashedUsername, sdCardPath); break; case Intent.ACTION_MEDIA_MOUNTED: sdCardAvailable = true; handleSDCardMounted(context, hashedUsername); break; } EventBus.getDefault().postSticky(new MediaStatusChangeEvent(sdCardAvailable)); } }
Example 2
Source File: StatusServiceImpl.java From Cangol-appcore with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction() == Intent.ACTION_MEDIA_EJECT) { //do nothings } else if (intent.getAction() == Intent.ACTION_MEDIA_SHARED) { //do nothings } else if (intent.getAction() == Intent.ACTION_MEDIA_BAD_REMOVAL) { //do nothings } else if (intent.getAction() == Intent.ACTION_MEDIA_REMOVED) { notifyStorageRemove(context); } else if (intent.getAction() == Intent.ACTION_MEDIA_MOUNTED) { notifyStorageMount(context); } }
Example 3
Source File: MediaMountedReceiver.java From edslite with GNU General Public License v2.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { Logger.debug("MediaMountedReceiver"); LocationsManagerBase lm = _lm; if(lm == null) return; String mountPath = intent.getDataString(); ExternalStorageLocation loc = mountPath != null ? new ExternalStorageLocation(context, "ext storage", mountPath, null) : null; try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } switch (intent.getAction()) { case UsbManager.ACTION_USB_DEVICE_ATTACHED: Logger.debug("ACTION_USB_DEVICE_ATTACHED"); lm.updateDeviceLocations(); LocationsManager.broadcastLocationAdded(context, loc); break; case Intent.ACTION_MEDIA_MOUNTED: Logger.debug("ACTION_MEDIA_MOUNTED"); lm.updateDeviceLocations(); LocationsManager.broadcastLocationAdded(context, loc); break; case Intent.ACTION_MEDIA_UNMOUNTED: Logger.debug("ACTION_MEDIA_UNMOUNTED"); lm.updateDeviceLocations(); LocationsManager.broadcastLocationRemoved(context, loc); break; case Intent.ACTION_MEDIA_REMOVED: Logger.debug("ACTION_MEDIA_REMOVED"); lm.updateDeviceLocations(); LocationsManager.broadcastLocationRemoved(context, loc); break; case UsbManager.ACTION_USB_DEVICE_DETACHED: Logger.debug("ACTION_USB_DEVICE_DETACHED"); lm.updateDeviceLocations(); LocationsManager.broadcastLocationRemoved(context, loc); break; } }