本文介绍了在Android的奇巧刷新图库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何刷新画廊在android系统奇巧?
How to refresh gallery the in android kitkat ?
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
我试着用上面的,但其在Android 4.4的不清爽。如何刷新画廊时添加/删除图像编程?
I tried with the above, but its not refreshing in android 4.4. How to refresh the gallery when add/delete the images programatically ?
推荐答案
这对我的作品:)
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");
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")));
}
希望它能帮助:)
Hope it helps :)
这篇关于在Android的奇巧刷新图库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!