为什么Images.Media.insertImage返回null [英] Why Images.Media.insertImage return null

查看:906
本文介绍了为什么Images.Media.insertImage返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些code,我运行的方法MediaStore.Images.Media.insertImage(从源不是一个文件名,将其插入),这code将图像保存到MediaStore和返回的URI图片。我知道,当它由于某种原因失败,将返回null,而不是一个URI。此图片已被下载多次受到很多人的,每隔一段时间就会返回null从此方法。我从未有过这种事发生在我,所以我不知道是怎么回事。是什么原因,这可能发生吗?还有另一篇文章(http://stackoverflow.com/questions/6576217/most-likely-cause-for-android-provider-mediastore-images-media-insertimage-to-re)有同样的问题,但得到的答复是链接到源$ C ​​$下MediaStore,但该链接进入一个页面,指出该链接不可用。任何帮助将是AP preciated。谢谢你。

I have some code where I run the method MediaStore.Images.Media.insertImage (inserting it from a source not a file name), This code saves the image to the MediaStore and returns the uri of the image. I know that when it fails for any reason it will return null instead of a uri. This image has been downloaded multiple times by many people and every once in a while it will return null from this method. I have never had this happen to me so I have no idea what is going on. What are reasons why this could happen? There is another post (http://stackoverflow.com/questions/6576217/most-likely-cause-for-android-provider-mediastore-images-media-insertimage-to-re) with the same issue but the answer is a link to the source code for MediaStore but that link goes to a page saying the link is unavailable. Any help would be appreciated. Thanks.

删除我我得到这个错误的SD卡后,所以我知道这可能是一个原因,我不知道,但我觉得,它也会发生,如果存储卡已满。还是只是想知道是否有可能是另一个原因了。

After removing my SD card I got this error so I know that could be a reason, I'm not sure but I feel that it would also happen if the card was full. Still just wondering if there could be another reason too.

推荐答案

这似乎发生,当你没有一个/ SD卡/ DCIM /摄像机上的一些Android版本的目录。创建这个目录(并具有的权限),解决了这个问题对我来说。

It seems to happen when you don't have an /sdcard/DCIM/Camera directory on some versions of Android. Creating this directory (and having the permission) solved the problem for me.

这篇关于为什么Images.Media.insertImage返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆