Android 在库中打开远程图像
我有一个带有缩略图的应用程序,当用户触摸拇指时,我想全屏打开完整图像。我尝试在默认的Gallery应用程序中打开图像,但它不能在所有设备上运行 以下是片段: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.
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的解决方案链接