0

Is there any way to create an intent that will open that gallery and will show a specific image in there? I'm not asking about saving the image to the memory but I just want a proper and easy way to show the image (not in an ImageView) in such a way that zooming will be available.

Daniel Reyhanian
  • 579
  • 4
  • 26

1 Answers1

1

You can use Intent and ACTION_VIEW to achieve that:

Intent intent = new Intent();  
intent.setAction(android.content.Intent.ACTION_VIEW);
Uri uri = Uri.parse("file://" + "YOUR_FILE's PATH");
//Or you can use                 
Uri uri = Uri.fromFile(new File("YOUR_FILE's PATH"));
intent.setDataAndType(uri,"image/*");
startActivity(intent);

If you're targeting or the device is API level 24+, refer to this answer to see how to get the proper Intent and avoid FileUriExposedException

Jack
  • 5,354
  • 2
  • 29
  • 54