如何以intent.ACTION_VIEW显示图像 [英] How to display image with intent.ACTION_VIEW
本文介绍了如何以intent.ACTION_VIEW显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的语法可以在android 5.1上运行,但不能在android 7.1上运行....
My grammar can run at android 5.1 but is not working at android 7.1....
File file = new File(Environment.getExternalStorageDirectory(), "Pictures/1481853170451.jpg");
Toast.makeText(MainActivity.this, file.getPath(), Toast.LENGTH_LONG).show();
Uri path = Uri.fromFile(file);
if (file.exists()) {
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(path, "image/*");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
this.startActivity(intent);
} catch (ActivityNotFoundException e) {
}
任何人都可以告诉我可能的答案.预先谢谢您....
Can any one tell me possible answer. Thank you in advance....
推荐答案
只需执行以下 查看全文