Fareed
Fareed

Reputation: 560

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

Upvotes: 0

Views: 1082

Answers (1)

Martin Cazares
Martin Cazares

Reputation: 13705

The activity not found exception is thrown because the schema "android.resource://com.app.mid/" do not match any of the view actions defined in android, the drawable object you are trying to see lives in your APK hence in order to do what you want, you need to come up with some sort of gallery/viewer on your own, but as another approach what you could do is store the drawable in the Media device as a file, and then try to open the default gallery as you are trying right now, but with the proper URI...

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

Upvotes: 1

Related Questions