本文整理匯總了Java中android.media.MediaScannerConnection.OnScanCompletedListener方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaScannerConnection.OnScanCompletedListener方法的具體用法?Java MediaScannerConnection.OnScanCompletedListener怎麽用?Java MediaScannerConnection.OnScanCompletedListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.media.MediaScannerConnection
的用法示例。
在下文中一共展示了MediaScannerConnection.OnScanCompletedListener方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: scanFile
import android.media.MediaScannerConnection; //導入方法依賴的package包/類
/**
* 掃描指定的文件
*
* @param context
* @param filePath
* @param sListener
*/
public static MediaScannerConnection scanFile(Context context, String[] filePath, String[] mineType,
MediaScannerConnection.OnScanCompletedListener sListener) {
ClientProxy client = new ClientProxy(filePath, mineType, sListener);
try {
MediaScannerConnection connection = new MediaScannerConnection(
context.getApplicationContext(), client);
client.mConnection = connection;
connection.connect();
return connection;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例2: onFileSaved
import android.media.MediaScannerConnection; //導入方法依賴的package包/類
private void onFileSaved(String filePath, int outputDestination) {
String msg = String.format("File saved: %s", filePath);
showToast(msg);
Log.d(TAG, msg);
MediaScannerConnection.OnScanCompletedListener scanListener = null;
// if this is a share operation add post-scan listener to kick off share
// listener is optional, not needed for export
if (outputDestination == SaveImageService.INTENT_SHARE) {
scanListener = mfileScanListener;
mShareImagePath = filePath;
}
MediaScannerConnection.scanFile(this, new String[]{filePath}, null, scanListener);
}
示例3: scanAndDeleteFile
import android.media.MediaScannerConnection; //導入方法依賴的package包/類
public static void scanAndDeleteFile(final Context context, final File file) {
MediaScannerConnection.OnScanCompletedListener listener =
new MediaScannerConnection.OnScanCompletedListener() {
@Override
public void onScanCompleted(String path, Uri uri) {
if (path == null)
return;
File scannedFile = new File(path);
if (scannedFile.equals(file)) {
//noinspection ResultOfMethodCallIgnored
file.delete();
MediaScannerConnection.scanFile(context, new String[]{file.getAbsolutePath()}, null, null);
}
}
};
MediaScannerConnection.scanFile(context, new String[] { file.getAbsolutePath() }, null, listener);
}
示例4: ClientProxy
import android.media.MediaScannerConnection; //導入方法依賴的package包/類
ClientProxy(String[] paths, String[] mimeTypes,
MediaScannerConnection.OnScanCompletedListener client) {
mPaths = paths;
mMimeTypes = mimeTypes;
mClient = client;
}
示例5: scanSdCard
import android.media.MediaScannerConnection; //導入方法依賴的package包/類
public void scanSdCard(Context context, @Nullable MediaScannerConnection.OnScanCompletedListener listener) {
MediaScannerConnection.scanFile(context, new String[]{Environment
.getExternalStorageDirectory().getAbsolutePath()}, null, listener);
}
示例6: scanFile
import android.media.MediaScannerConnection; //導入方法依賴的package包/類
public static void scanFile(String filePath, final String type, final MediaScannerConnection.OnScanCompletedListener listener) {
String[] paths = new String[1];
paths[0] = filePath;
String[] mimeTypes = new String[1];
mimeTypes[0] = type;
MediaScannerConnection.scanFile(sContext, paths, mimeTypes, listener);
}
示例7: scanImage
import android.media.MediaScannerConnection; //導入方法依賴的package包/類
/**
* 掃描多媒體文件
*
* @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);
}