从sdk v24开始,是否可以在Android Gallery中打开相册?
我有一个应用程序,可以操作图像并将其保存到外部存储器中的特定相册名称下。 我希望应用程序能够直接在Android Gallery中打开该相册。 是否可以实现这一点?
我可以轻松地打开单个文件,但无法打开整个相册:
我的 AndroidManifest.xml
...
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
...
我的
provider_paths.xml
文件<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>
我打开一个 特定文件 的处理方式:
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
File myFile = new File(new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), MY_ALBUM_NAME), MY_FILE_NAME);
Uri myUri = FileProvider.getUriForFile(context, context.getPackageName() + ".provider", myFile);
i.setDataAndType(myUri, "image/*");
i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(i);
打开特定的文件没问题。但是我无法让它打开整个相册。这可能吗?