我在我的應用程序,爲(我的應用程序內)打開畫廊行之有效的一些代碼,選擇一張照片,並上傳。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