List of usage examples for android.media MediaScannerConnection scanFile
public static void scanFile(Context context, String[] paths, String[] mimeTypes, OnScanCompletedListener callback)
From source file:Main.java
public static void updateSystemMedia(Context context) { MediaScannerConnection.scanFile(context, new String[] { android.os.Environment.getExternalStorageDirectory().getAbsolutePath() }, null, null);// w w w . j a v a 2 s . com }
From source file:Main.java
public static void updateResources(Context context, String path) { MediaScannerConnection.scanFile(context, new String[] { path }, null, null); }
From source file:Main.java
public static void addNewFileToDB(Context context, String path) { MediaScannerConnection.scanFile(context, new String[] { path }, null, null); }
From source file:Main.java
public static void scanFile(Context context, File file) { MediaScannerConnection.scanFile(context, new String[] { file.getAbsolutePath() }, new String[] { "image/jpeg" }, null); }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.FROYO) public static void scanFile(Context context, String path) { MediaScannerConnection.scanFile(context, new String[] { path }, null, null); }
From source file:Main.java
public static void writeFiletoAndroidMediaDB(Context context, File file) { MediaScannerConnection.scanFile(context, new String[] { file.toString() }, null, new MediaScannerConnection.OnScanCompletedListener() { public void onScanCompleted(String path, Uri uri) { }/*from ww w . j ava 2s . com*/ }); }
From source file:Main.java
public static void addPhotoToMediaStoreSynchronously(Context context, Uri uri) { MediaScannerConnection.scanFile(context, new String[] { uri.getPath() }, new String[] { "image/*" }, new MediaScannerConnection.OnScanCompletedListener() { public void onScanCompleted(String path, Uri uri) { Log.i("MediaStore", "Scanned " + path + ":"); Log.i("MediaStore", "-> uri=" + uri); }//from w w w.j a v a 2 s . c o m }); }
From source file:Main.java
public static void mediaScannerCall(final Context context, final File file) { new AsyncTask<Void, Void, Void>() { @Override/*w w w . j av a 2 s. co m*/ protected Void doInBackground(Void... params) { MediaScannerConnection.scanFile(context, new String[] { file.toString() }, null, new MediaScannerConnection.OnScanCompletedListener() { public void onScanCompleted(String path, Uri uri) { Log.i("ExternalStorage", "Scanned " + path + ":"); Log.i("ExternalStorage", "-> uri=" + uri); } }); return null; } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null); }
From source file:Main.java
/** * Trigger the media scanner to ensure files show up in MTP. * @param context a context to use for communication with the media scanner * @param scanfile directory or file to scan *//*from w w w .jav a2 s . c o m*/ @TargetApi(11) private static void triggerMediaScanner(Context context, File scanfile) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) return; // API 11 - lower versions do not have MTP try { String path = scanfile.getCanonicalPath(); Log.i("SavingHelper", "Triggering media scan for " + path); MediaScannerConnection.scanFile(context, new String[] { path }, null, new OnScanCompletedListener() { @Override public void onScanCompleted(String path, Uri uri) { Log.i("SavingHelper", "Media scan completed for " + path + " URI " + uri); } }); } catch (Exception e) { Log.e("SavingHelper", "Exception when triggering media scanner", e); } }
From source file:Main.java
public static void scanMediaFiles(final Context context, String[] files, String[] mimeTypes) { MediaScannerConnection.scanFile(context, files, mimeTypes, new OnScanCompletedListener() { @Override// w w w . j a v a 2 s . c om public void onScanCompleted(String arg0, Uri arg1) { Log.i("weitu", "arg0:" + arg0 + ";arg1:" + arg1); } }); }