我在我的应用程序,为(我的应用程序内)打开画廊行之有效的一些代码,选择一张照片,并上传。Android图库“通过共享”和Intent.EXTRA_STREAM
我在集成处理与连接EXTRA_STREAMs,比如在图片库中的“共享”按钮生成的意图做了一个公平的尝试。
这适用于我的Droid X,它适用于模拟器。
今天,我收到了用户的错误报告,我用来拉的照片出来的MediaStore的光标返回null当我问它返回我的资源中提到的EXTRA_STREAM参数。代码已经通过验证Intent附加了EXTRA_STREAM的点,并且用户告诉我他们正在使用库中的“share”选项。
他们的设备是:
OS版本:2.3.3(10/GRI40) 设备:HTC PG86100
是怎么回事?
为什么HTC画廊会向我发送我无法访问的EXTRA_STREAM的意图?
是否有任何其他原因游标将返回null?
String[] filePathColumn = {MediaColumns.DATA};
Uri selectedImageUri;
//Selected image returned from another activity
if(fromData){
selectedImageUri = imageReturnedIntent.getData();
} else {
//Selected image returned from SEND intent
// This is the case that I'm having a problem with.
// fromData is set in the code that calls this;
// false if we've been called from an Intent that has an
// EXTRA_STREAM
selectedImageUri = (Uri)getIntent().getExtras().get(Intent.EXTRA_STREAM);
}
Cursor cursor = getContentResolver().query(selectedImageUri, filePathColumn, null, null, null);
cursor.moveToFirst(); // <-- NPE on this line