gpt4 book ai didi

android - 在android kitkat中刷新画廊

转载 作者:行者123 更新时间:2023-11-29 01:47:55 25 4
gpt4 key购买 nike

如何在 android kitkat 中刷新图库?

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));

我尝试了上面的方法,但它在 android 4.4 中没有刷新。以编程方式添加/删除图像时如何刷新图库?

最佳答案

这对我有用:)

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")));
}

希望对您有所帮助:)

关于android - 在android kitkat中刷新画廊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20265438/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com