您的位置:首页 > 其它

插入新图片Gallery不更新

2012-08-21 17:29 92 查看
目前在做一个应用,需要在应用中保存图片到照片目录 /mnt/sdcsrd/DCIM/Camera ,但是图片保存以后在Gallery 中看不到插入的图片。

搜了很多网站,终于找到解决方法:

插入图片后,运行 Media scanner,更新图片库:

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

另外需要在 AndroidManifest.xml 中添加语句:

<intent-filter >
<action android:name="android.intent.action.MEDIA_MOUNTED" />

<data android:scheme="file" />
</intent-filter>


再运行就可以正常更新了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: