【问题标题】:open image from drawable using android gallery app使用 android 图库应用程序从可绘制的图像中打开图像
【发布时间】:2013-06-06 16:03:23
【问题描述】:

我的应用程序有 12 张图片保存在 drawable 中,我在 12 个项目的列表中制作,所以如果按下任何项目,它应该打开相应的图像。 我想通过默认图库应用程序打开这些图像。 我试过这个

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); 

但它给了我错误:ActivityNotFoundException,没有找到处理意图的活动。

我该怎么办?在此先感谢:)

【问题讨论】:

    标签: android android-intent android-activity android-imageview android-gallery


    【解决方案1】:

    Activity not found 异常被抛出,因为架构“android.resource://com.app.mid/”不匹配任何在 android 中定义的视图操作,您试图查看的可绘制对象存在于您的APK 因此,为了做你想做的事,你需要自己想出某种画廊/查看器,但作为另一种方法,你可以做的是将可绘制对象作为文件存储在媒体设备中,然后尝试按照您现在的尝试打开默认图库,但使用正确的 URI...

    startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("content://media/external/images/media"))); 
    

    【讨论】:

    • 我不明白.. 我需要一个例子或任何其他帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-30
    • 2014-09-29
    相关资源
    最近更新 更多