Android How to view an image using its path to an SDcard file from my application

The file is present in sdcard/image.jpg
I would like to create my own application (activity). When a button is pressed, the image stored on the SD card should be displayed using the integrated image viewer. When I click the back button in the image viewer, it should return to my running application.

Help is needed.

+5
source share
2 answers
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);

This code is used to display all the images from your SD card.

+6
source

You can create an intent with the 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);
+11

All Articles