简体   繁体   English

当我在列表中找到这些图像的Uris时,如何使用画廊使用意图从外部存储查看多个图像

[英]How do I use gallery to view multiple images from external storage using intents when I hava Uris of those images in a list

I want to open multiple images in default image viewing apps(gallery, google photos,etc.) from an array list of URIs of images. 我想从图像URI的数组列表中在默认图像查看应用程序(图库,谷歌照片等)中打开多个图像。 But what I have achieved so far is that it opens first image in my arraylist contaning URIs of those images. 但是到目前为止,我所取得的成就是,它在我的arraylist中打开了包含这些图像URI的第一张图像。 I have android 8.0. 我有android 8.0。

I have included following in my manifest 我的清单中包含以下内容

<provider
    android:name="androidx.core.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>

in res/xml/provider_paths 在res / xml / provider_paths中

<?xml version="1.0" encoding="utf-8"?>
<paths>
    <!--<external-path name="external_files" path="."/>-->
    <external-path
        name="files_root"
        path="Android/data/${applicationId}"/>
    <external-path
        name="external_storage_root"
        path="."/>
</paths>

I am calling this method in my onClickListener of 我在我的onClickListener中调用此方法

private void viewImage(ArrayList<String> list) {


    File file = new File(list.get(0));
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? FileProvider.getUriForFile(mCtx, getPackageName() + ".provider", file) : Uri.fromFile(file),
            "image/jpeg").addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    mCtx.startActivity(Intent.createChooser(intent, "Open"));
}

I want to open multiple images in default image viewing apps 我想在默认的图像查看应用程序中打开多个图像

There is no Intent action for that, sorry. 对此,没有Intent操作。

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

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