is MediaStore Scan Running - Android android.provider

Android examples for android.provider:MediaStore

Description

is MediaStore Scan Running

Demo Code


import java.io.File;
import android.annotation.SuppressLint;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import android.provider.MediaStore.Audio;
import android.provider.MediaStore.Files;
import android.provider.MediaStore.Images;
import android.provider.MediaStore.Video;
import android.util.Log;

public class Main{
    private static final String TAG = MediaStoreHelper.class
            .getSimpleName();/* w w w. j  av  a 2  s  . c o m*/
    private static final boolean LOCAL_LOGV = false;
    
    public static boolean isScanRunning(ContentResolver cr) {
        Cursor cursor = cr.query(MediaStore.getMediaScannerUri(),
                new String[] { MediaStore.MEDIA_SCANNER_VOLUME }, null,
                null, null);
        if (cursor == null) {
            return false;
        }
        cursor.moveToFirst();
        int index = cursor.getColumnIndex(MediaStore.MEDIA_SCANNER_VOLUME);
        String volume = cursor.getString(index);
        cursor.close();
        if (LOCAL_LOGV) {
            Log.v(TAG, "isScanRunning: volume=" + volume);
        }
        return volume != null;
    }
}

Related Tutorials