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.
Asked
Active
Viewed 621 times
2 Answers
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.

Ivan Alburquerque
- 731
- 9
- 14