Example usage for android.media MediaScannerConnection isConnected

List of usage examples for android.media MediaScannerConnection isConnected

Introduction

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

Prototype

public synchronized boolean isConnected() 

Source Link

Document

Returns whether we are connected to the media scanner service

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;/*from   w  w w  .j ava2  s.  c o m*/
    }
    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?
    }
}