Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在库中打开远程图像_Android - Fatal编程技术网

Android 在库中打开远程图像

Android 在库中打开远程图像,android,Android,我有一个带有缩略图的应用程序,当用户触摸拇指时,我想全屏打开完整图像。我尝试在默认的Gallery应用程序中打开图像,但它不能在所有设备上运行 以下是片段: Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url_of_the_remote_image_here)); intent.setType("image/jpg"); startActivity(intent); 在运行4.1的Nexus S上,我得到: android.

我有一个带有缩略图的应用程序,当用户触摸拇指时,我想全屏打开完整图像。我尝试在默认的Gallery应用程序中打开图像,但它不能在所有设备上运行

以下是片段:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url_of_the_remote_image_here));
intent.setType("image/jpg");
startActivity(intent);
在运行4.1的Nexus S上,我得到:

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

我尝试了几段代码,其中很多都是在浏览器中打开图像的。因为所有的Android设备都有默认的多媒体资料,难道不能用它打开远程图像吗?

你不应该认为有活动来处理你的互联网,所以总是在
try/catch
中包装
startActivity()
。我会使用正确的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();
}
我可能有你的答案。提问者能够在浏览器中显示该问题。然后有一个使用Intent的解决方案链接