项目中遇到 录屏后通知系统相册刷新
/** Receiver扫描更新图库 **/
public static void refreshAlbumByReceiver(Context context, String path) {
context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
Uri.parse("file://" + path)));
}
/**
* 刷新相册
* @param path
*/
public static void refrshAlbumByMediaScannerConnection(Context context,String path) {
String[] paths = {path};
String[] mimeTypes = {"image/jpeg", "image/png"};
MediaScannerConnection.scanFile(context, paths, mimeTypes,
new MediaScannerConnection.OnScanCompletedListener() {
@Override
public void onScanCompleted(String path, Uri uri) {
}
});
}
/**
* 刷新相册
* @param path
*/
public static void refreshAlbumByMediaScannerConnectionMP4(Context context, String path) {
String[] paths = {path};
String[] mimeTypes = {"video/mp4"};
MediaScannerConnection.scanFile(context, paths, mimeTypes,
new MediaScannerConnection.OnScanCompletedListener() {
@Override
public void onScanCompleted(String path, Uri uri) {
}
});
}