2014-12-06 92 views
0

我試圖從存儲加載圖像,但應用程序崩潰,並給了我這個錯誤:當從存儲的應用程序加載圖像崩潰

12-06 22:08:41.539: E/AndroidRuntime(28957): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file://[email protected]:///storage/emulated/0/My Folder/1417896511752.jpg } 
12-06 22:08:41.539: E/AndroidRuntime(28957): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1660) 
12-06 22:08:41.539: E/AndroidRuntime(28957): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1430) 

這是我的代碼,我使用

Intent intent = new Intent(); 
       intent.setAction(Intent.ACTION_VIEW); 
       intent.setDataAndType(Uri.parse("file://" + bitmap + fileUri), null); 
       startActivity(intent); 
      return; 
      } 
     }); 

不知道我做錯了這裏,就好像我以前`刪除Uri.parse(「文件.....)的意圖不工作;

可以在任何一個可以幫助我,請

謝謝

回答

1

嘗試修改此行

intent.setDataAndType(Uri.parse("file://" + bitmap + fileUri), null); 

intent.setDataAndType(Uri.parse("content://" + bitmap + fileUri), "image/*"); 
+0

非常感謝!有用! – Allrounder 2014-12-06 20:33:32

0

你沒有處理你的意圖的活動 試試這個。

if (intent.resolveActivity(getPackageManager()) != null) { 
    startActivity(intent); 
} 
+0

感謝,它現在不崩潰,但沒有任何反應。有沒有錯誤或任何東西? – Allrounder 2014-12-06 20:28:53

+0

它不顯示圖像。 – Allrounder 2014-12-06 20:29:21

+0

它不顯示圖像,因爲您沒有處理您的意圖的活動(應用程序)。 – Vigen 2014-12-06 20:31:30

0

你沒有活動,那就是錯誤的意思。也許你可以在致電startActivity()之前查看活動。

另外,移除Uri.parse後,務必可以使用?因爲它不應該像setDataAndType那樣需要一個URI作爲數據而不是一個String,所以它應該是一個錯誤。

相關問題