本文整理汇总了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);
}