List of usage examples for android.content Intent ACTION_MEDIA_MOUNTED
String ACTION_MEDIA_MOUNTED
To view the source code for android.content Intent ACTION_MEDIA_MOUNTED.
Click Source Link
From source file:Main.java
public static void allScan(Context context) { context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); }
From source file:Main.java
public static void allScan(Context context) { if (null == context) { return;//w w w . j a v a 2s. c om } context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + android.os.Environment.getExternalStorageDirectory()))); }
From source file:Main.java
public static void notifyFileSystemChanged(String path, Context mContext) { if (path == null) return;//www.j a v a 2s . c o m final File f = new File(path); final Intent intent; if (f.isDirectory()) { intent = new Intent(Intent.ACTION_MEDIA_MOUNTED); intent.setClassName("com.android.providers.media", "com.android.providers.media.MediaScannerReceiver"); intent.setData(Uri.fromFile(Environment.getExternalStorageDirectory())); } else { intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); intent.setData(Uri.fromFile(new File(path))); } mContext.sendBroadcast(intent); }
From source file:Main.java
/** * Forces the Android gallery to refresh its thumbnail images. * @param context//from w w w . j a v a 2 s . co m * @param fdelete */ private static void refreshGalleryImages(Context context, File fdelete) { try { context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); } catch (Exception e1) { try { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); Uri contentUri = Uri.fromFile(fdelete); mediaScanIntent.setData(contentUri); context.sendBroadcast(mediaScanIntent); } catch (Exception e2) { } } }
From source file:Main.java
/** * /*from w w w .j a v a 2 s. c o m*/ * @param context */ public static void notifyScanMediaFiles(Context context) { context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); }
From source file:Main.java
/** * Deletes an image given its Uri.//from www .ja va 2 s . c o m * * @param cameraPicUri * @param context * @return true if it was deleted successfully, false otherwise. */ public static boolean deleteImageWithUriIfExists(Uri cameraPicUri, Context context) { if (cameraPicUri != null) { File fdelete = new File(cameraPicUri.getPath()); if (fdelete.exists()) { if (fdelete.delete()) { context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); return true; } } } return false; }
From source file:org.chromium.ChromeSystemStorage.java
private static BackgroundEventHandler<ChromeSystemStorage> createEventHandler() { return new BackgroundEventHandler<ChromeSystemStorage>() { @Override// w w w . j av a2 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.musicmod.android.dialog.ScanningProgress.java
@Override public void onStart() { super.onStart(); registerReceiver(mMountStateReceiver, new IntentFilter(Intent.ACTION_MEDIA_MOUNTED)); }
From source file:org.videolan.vlc.gui.tv.browser.BaseTvActivity.java
@Override protected void onResume() { super.onResume(); mIsVisible = true;/*from ww w . j ava 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); }