如何在android kitkat刷新画廊?
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
我试过上面的内容,但它在android 4.4中并不令人耳目一新。以编程方式添加/删除图像时如何刷新图库?
答案 0 :(得分:1)
试试这个:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
File f = new File("folderPATH", "fileName"); //OR File f = new File(YourCurrentPhotoPath);
Uri contentUri = Uri.fromFile(f);
mediaScanIntent.setData(contentUri);
appContext.sendBroadcast(mediaScanIntent);
} else {
appContext.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory() + "/" + "FOLDER_TO_REFRESH")));
}
多数民众赞成......