Reputation: 3
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);
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/* }
Upvotes: 0
Views: 1619
Reputation: 1007494
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.
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.
Upvotes: 4