Java Code Examples for android.media.MediaScannerConnection#OnScanCompletedListener

The following examples show how to use android.media.MediaScannerConnection#OnScanCompletedListener . 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: MediaUtil.java    From BaseProject with Apache License 2.0 5 votes vote down vote up
public static void notifySysMedia2Scan(Context context, MediaScannerConnection.OnScanCompletedListener callback, String toScanTheFilePath) {
    if (null == toScanTheFilePath) {
        toScanTheFilePath = Environment.getExternalStorageDirectory().getAbsolutePath();
    }
    if (!Util.isCompateApi(19)) {//android 4.4系统之前,发广播的方式通知系统去扫描
        context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
                Uri.parse("file://" + toScanTheFilePath)));
    }
    else{
        MediaScannerConnection.scanFile(context, new String[] {toScanTheFilePath}, null, callback);
    }
}
 
Example 2
Source File: MediaManager.java    From Musicoco with Apache License 2.0 4 votes vote down vote up
public void scanSdCard(Context context, @Nullable MediaScannerConnection.OnScanCompletedListener listener) {
    MediaScannerConnection.scanFile(context, new String[]{Environment
            .getExternalStorageDirectory().getAbsolutePath()}, null, listener);

}
 
Example 3
Source File: SingleMediaScanner.java    From mimi-reader with Apache License 2.0 4 votes vote down vote up
public SingleMediaScanner(final Context context, File f, @Nullable MediaScannerConnection.OnScanCompletedListener listener) {
    file = f;
    scanCompleteListener = listener;
    mediaScannerConnection = new MediaScannerConnection(context, this);
    mediaScannerConnection.connect();
}
 
Example 4
Source File: FileUtil.java    From quickhybrid-android with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * 扫描多媒体文件
 *
 * @param context
 * @param filename
 * @param listener
 */
public static void scanImage(Context context, String filename, MediaScannerConnection.OnScanCompletedListener listener) {
    MediaScannerConnection.scanFile(context, new String[]{filename}, null, listener);
}
 
Example 5
Source File: MediaUtil.java    From BaseProject with Apache License 2.0 2 votes vote down vote up
/**
 * 通知系统进行媒体文件的扫描任务
 * @param context
 */
public static void notifySysMedia2Scan(Context context, MediaScannerConnection.OnScanCompletedListener callback) {
    notifySysMedia2Scan(context, callback, null);
}