0

I am doing an Android file explorer. How can I execute a file? For example : "/xxx/xxx/image.jpg" I need to display the image in the default android system image viewer when the user clicks on the name of the file.

Jorge M
  • 33
  • 1
  • 3
  • You need to send an Intent. I think that this answer might help you: http://stackoverflow.com/a/17831722/4568679 – Slav Sep 29 '16 at 17:42

2 Answers2

1

You can use an intent to do that.

Intent intent = new Intent();
//Action View to see an image in default native app in your device.
intent.setAction(Intent.ACTION_VIEW);
//The path to see your image.
intent.setDataAndType(Uri.parse("file://" + "/sdcard/test.jpg"), "image/*");
startActivity(intent);
Luiz Fernando Salvaterra
  • 4,192
  • 2
  • 24
  • 42
0

Without knowing much about the code itself you can try with:

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

ACTION_VIEW as per Android Documentation:

Display the data to the user. This is the most common action performed on data -- it is the generic action you can use on a piece of data to get the most reasonable thing to occur.