Android如何使用SDcard中的文件路径从我的应用程序预览图像

Roy*_*uel 5 android image view preview

文件存在于sdcard/image.jpg
我想创建自己的应用程序(活动).按下按钮时,需要使用内置图像查看器显示存储在SD卡中的图像.按下图像查看器中的后退按钮,它应该返回到我正在运行的应用程序.

需要一些帮助.

bhu*_*ups 11

你可以用适当的uri和mimetype为它创建一个Intent.

Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse("file:///sdcard/image.jpg"), "image/jpeg");
startActivity(i);
Run Code Online (Sandbox Code Playgroud)


小智 5

Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);
Run Code Online (Sandbox Code Playgroud)

此代码用于显示SD卡中的所有图像