2013-06-27 71 views
0

我有一个缩略图的应用程序,当用户触摸一个拇指时,我想以全屏模式打开完整图像。我尝试在默认的Gallery应用程序中打开图像,但它不适用于所有设备。在图库中打开远程图像

这里的片段:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url_of_the_remote_image_here)); 
intent.setType("image/jpg"); 
startActivity(intent); 

在歌Nexus S运行Android 4.1,我得到:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW typ=image/jpg } 

我尝试的代码片段数,许多人在浏览器中打开图像。由于所有Android设备都有默认图库,因此不应该可以使用它来打开远程图像吗?

回答

0

你永远不应该认为有活动来处理你的intenet,所以总是把startActivity()换成try/catch。我会使用正确的MIME类型image/jpeg,但实际上我会用更通用的image/*替换它。

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url_of_the_remote_image_here)); 
intent.setType("image/*"); 
try { 
    startActivity(intent); 
} catch(Exception e) { 
    e.printStatckTrace(); 
} 
0

This可能有你的答案。提问的人能够在浏览器中显示它。然后使用Intent链接到解决方案。