5

File is present in sdcard/image.jpg
I would like to create my own application (activity). On a button press, the image stored in the sdcard needs to be displayed using the built-in image viewer. On pressing the back button from the Image viewer, it should go back to my running application.

Need some help.

DonGru
  • 13,532
  • 8
  • 45
  • 55
Roy Samuel
  • 790
  • 9
  • 24

2 Answers2

11

you can create an Intent with proper uri and mimetype for this.

Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse("file:///sdcard/image.jpg"), "image/jpeg");
startActivity(i);
bhups
  • 14,345
  • 8
  • 49
  • 57
5
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);

This code use for display all images from your SD card

antiway
  • 74
  • 3