我想制作一个像相册一样的库并将其改编成Android Q
由于范围存储,MediaStore.Images.ImageColumns.DATA
已弃用;
我们不能直接通过路径读取文件 /storage/emulated/0/DCIM/xxx.png
MediaStore.Images.ImageColumns
没有像 URI 这样的值,所以我无法通过 ContentProvider 获取图片。
这种方式我们只能打开一张图片(下面的代码),在回调中接收到一个URI;
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
// Filter to only show results that can be "opened", such as a
// file (as opposed to a list of contacts or timezones).
intent.addCategory(Intent.CATEGORY_OPENABLE);
// Filter to show only text files.
intent.setType("image/*");
Run Code Online (Sandbox Code Playgroud)
但是我想访问所有图片,那么,如何在 Android Q 中扫描所有图片?