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

a 夏天 提交于 2019-12-06 03:43:10

问题


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.


回答1:


Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);

This code use for display all images from your SD card




回答2:


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);


来源:https://stackoverflow.com/questions/3820949/android-how-to-preview-an-image-using-its-file-path-from-sdcard-from-my-applic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!