[英]open image from drawable using android gallery app
My app has 12 pictures saved in drawable, and i made on a list of 12 item, so if any item pressed it should open the corresponding image. 我的应用程序有12张图片保存在drawable中,并且我在12个项目的列表中进行了绘制,因此如果按下任何项目,则应打开相应的图像。 I want to open these images by default gallery application.
我想通过默认图库应用程序打开这些图像。 i tried this
我尝试了这个
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("android.resource://com.app.mid/" + R.drawable.pic10), "image/png");
startActivity(intent);
But it gives me error :ActivityNotFoundException, No activity found to handle intent. 但这给了我错误:ActivityNotFoundException,找不到活动来处理意图。
What should i do ? 我该怎么办 ? Thanks in advance :)
提前致谢 :)
由于架构“ android.resource://com.app.mid/”与android中定义的任何视图操作都不匹配,因此引发了活动未找到异常,因为您试图查看的可绘制对象存在于APK中,因此位于为了执行您想要的操作,您需要自己提供某种图库/查看器,但是作为另一种方法,您可以做的是将drawable作为文件存储在Media设备中,然后尝试打开默认值您现在正在尝试的图片库,但是具有正确的URI ...
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("content://media/external/images/media")));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.