简体   繁体   中英

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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM