-
-
Save dzwillpower/6460384 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.app; | |
import java.io.File; | |
import android.media.MediaScannerConnection; | |
import android.media.MediaScannerConnection.MediaScannerConnectionClient; | |
import android.net.Uri; | |
import android.util.Log; | |
public class MyMediaScannerConnectionClient implements MediaScannerConnectionClient { | |
private File mScanDir; | |
private MediaScannerConnection mScanner; | |
public MyMediaScannerConnectionClient(File dir) { | |
mScanDir = dir; | |
} | |
@Override | |
public void onMediaScannerConnected() { | |
File[] files = mScanDir.listFiles(); | |
for (File f : files) { | |
String path = f.getAbsolutePath() | |
mScanner.scanFile(path, null); | |
Log.i("MyMediaScannerConnectionClient", "Media Scan completed on file: path=" + path); | |
} | |
} | |
@Override | |
public void onScanCompleted(String path, Uri uri) { | |
Log.i("MyMediaScannerConnectionClient", "Media Scan completed on directory: path=" + path + " uri=" + uri); | |
mScanner.disconnect(); | |
mScanner = null; | |
} | |
public void setScanner(MediaScannerConnection scanner) { | |
mScanner = scanner; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment