简体   繁体   English

无法打开具有特定文件夹链接的Android打开默认图库

[英]Android open default gallery with specific folder link cannot be loaded

I am trying to open the folder containing captured photos by default-Gallery in Android . 我正在尝试在Android中默认情况下打开包含图库照片的文件夹。

But after opening it, it shows "cannot be load" at the screen of the Gallery. 但是打开它后,它在图库的屏幕上显示“无法加载”。

Would you please tell me is there amything missing to pass the intent ? 您能告诉我是否缺少通过意图的神话?

The below is my code 下面是我的代码

public void buttonGallery(View v) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.parse(resultPhoto.getAbsolutePath()), "image/*");
    startActivity(intent);
}

... ...

File mediaStorageDir = new File(Environment.getExternalStorageDirectory() + File.separator + "NBA_FINAL_photo");
        resultPhoto = mediaStorageDir;

我认为您忘了在manifest.xml中设置Permisson

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

您必须在Uri中添加“ file://”

intent.setDataAndType(Uri.parse("file://" + resultPhoto.getAbsolutePath(), "image/*");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM