Open an image using URI in Android's default gallery image viewer

Badr Hari picture Badr Hari · Mar 21, 2011 · Viewed 163.9k times · Source

I have extracted image uri, now I would like to open image with Android's default image viewer. Or even better, user could choose what program to use to open the image. Something like File Explorers offer you if you try to open a file.

Answer

Vikas picture Vikas · Jul 21, 2011

Accepted answer was not working for me,

What had worked:

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + "/sdcard/test.jpg"), "image/*");
startActivity(intent);