Example usage for android.media MediaScannerConnection scanFile

List of usage examples for android.media MediaScannerConnection scanFile

Introduction

In this page you can find the example usage for android.media MediaScannerConnection scanFile.

Prototype

public void scanFile(String path, String mimeType) 

Source Link

Document

Requests the media scanner to scan a file.

Usage

From source file:com.frostwire.android.gui.UniversalScanner.java

private static void onMediaScannerConnected(MediaScannerConnection connection, Collection<File> files) {
    if (files == null || connection == null) {
        return;//  w w  w  . j  a v a2s. com
    }
    try {
        /* should only arrive here on connected state, but let's double check since it's possible */
        if (connection.isConnected() && !files.isEmpty()) {
            for (File f : files) {
                connection.scanFile(f.getAbsolutePath(), null);
            }
        }
    } catch (IllegalStateException e) {
        LOG.warn("Scanner service wasn't really connected or service was null", e);
        //should we try to connect again? don't want to end up in endless loop
        //maybe destroy connection?
    }
}