【发布时间】:2010-10-06 13:26:10
【问题描述】:
我想从一个 URL 打开一个图像到一个意图,很可能是浏览器或者像 twidroyd 中内置的那样的图片预览器。
Intent intent = new Intent();
Uri uri = Uri.parse("http://nssdc.gsfc.nasa.gov/image/planetary/earth/gal_new-zealand.jpg");
intent.setDataAndType(uri, "image/*");
intent.setAction(android.content.Intent.ACTION_GET_CONTENT);
startActivity(intent);
但是当我尝试时,我得到以下异常:
错误/AndroidRuntime(232): android.content.ActivityNotFoundException: 未找到处理 Intent { 的活动 act=android.intent.action.GET_CONTENT dat=http://nssdc.gsfc.nasa.gov/image/planetary/earth/gal_new-zealand.jpg 类型=图像/* }
我已经获得了可以在浏览器中打开的纯 URL。我只是不知道要指定什么动作或类别,我试过了:
intent.addCategory("CATEGORY_BROWSABLE");
// and
intent.addCategory("CATEGORY_OPENABLE");
如果我将操作设置为:它也不起作用:
android.content.Intent.ACTION_VIEW
有什么想法吗?
【问题讨论】: