【发布时间】:2015-05-30 02:11:07
【问题描述】:
我的app 无法为一小部分用户选择图像的实例加载位图。
我选择图片的代码是这样的:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT).setType("image/*");
那么我打开位图的代码是:
InputStream input = activity.getContentResolver().openInputStream(uri);
if (input == null)
throw new NullPointerException("Null returned from openInputStream for: " + uri);
然后我得到这样的异常:
java.lang.NullPointerException: 从 openInputStream 返回 Null 为了: 内容://com.sec.android.gallery3d.provider/picasa/item/5884758542207200626
java.lang.NullPointerException: 从 openInputStream 返回 Null 为了: 内容://com.sec.android.gallery3d.provider/picasa/item/6064868645826106994
【问题讨论】:
-
您是否拥有
READ_EXTERNAL_STORAGE或WRITE_EXTERNAL_STORAGE权限? -
是的,应用程序持有 WRITE_EXTERNAL_STORAGE
-
您是否立即要求
InputStream(例如,在onActivityResult()中)?还是您将Uri保存在某处(例如数据库)并尝试稍后访问它? -
我马上要 InputStream
-
好吧,如果所有的 URL 都是
com.sec.android.gallery3d.provider,那是三星的东西(com.sec),也许他们有一个错误。另见stackoverflow.com/questions/10735562/…
标签: android android-intent bitmap