Android的 - 从默认库的应用程序绘制打开的图像 [英] Android - open image from drawable in default gallery application
问题描述
我工作的应用程序,具有imageviews数,
当我在图像上单击我希望它通过Android的默认图库图片选择器打开。
我试过这样:
I'm working on app that have number of imageviews, when i click on the image i want it to open via android default gallery image picker. i've tried in this way :
String str = "android.resource://" + getPackageName() +"/"+R.drawable.wall1;
Uri path = Uri.parse(str);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(path, "image/*");
startActivity(intent);
但它不工作,我得到异常:
android.content.ActivityNotFoundException:无活动处理意向{行动= android.intent.action.VIEW DAT = android.resource://com.example.demo/2130837505典型值=图像/ *}
but it doesn't work and i get exception: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=android.resource://com.example.demo/2130837505 typ=image/* }
推荐答案
这是因为有能够查看驻留在一个图像的设备上没有任何活动乌里
与在安卓资源://
方案。如果我猜,〜Android设备的99%,将有一个类似的问题。
That is because there is no activity on your device capable of viewing an image residing at a Uri
with the android:resource://
scheme. If I had to guess, ~99% of Android devices will have a similar problem.
无论是写你自己的图像浏览器或移动某个地方的第三方应用程序更容易支持,图像等作为自己的的ContentProvider
或本地文件。
Either write your own image viewer, or move the image someplace that third-party apps are more likely to support, such as your own ContentProvider
or a local file.
这篇关于Android的 - 从默认库的应用程序绘制打开的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!