Android11(API30)上Android存储访问框架无法工作。
创始人
2024-08-20 09:00:58
0

为了在Android 11上访问外部存储,需要使用新的API来构建一个非常特定的意图。以下是代码示例:

// ACTION_OPEN_DOCUMENT is the intent to choose a file via the system's file
// browser.
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
    // Filter to only show results that can be "opened", such as a
    // file (as opposed to a list of contacts or timezones).
    addCategory(Intent.CATEGORY_OPENABLE)

    // Filter to show only images, using the image MIME data type.
    // If one wanted to search for ogg vorbis files, the type would be "audio/ogg".
    // To search for all documents available via installed storage providers,
    // it would be "*/*".
    type = "image/*"
}
startActivityForResult(intent, READ_REQUEST_CODE)

此代码示例中,我们使用Intent.ACTION_OPEN_DOCUMENT 创建一个意图来选择一个文件。该意图包含一个Intent.CATEGORY_OPENABLE过滤器,以确保该文件可以被打开。另外,我们还需要指定我们要搜索的文件类型,例如过滤器中的'image/*”,该意图将打开系统的文件浏览器并让用户选择要打开的文件。

相关内容

热门资讯

实测交流!wepoker透视脚... 实测交流!wepoker透视脚本免费使用视频,hhpoker辅助软件下载,力荐教程(有挂透视);科技...
揭秘!hhpoker哪个俱乐部... 揭秘!hhpoker哪个俱乐部靠谱,uupoker有透视吗,系统教程(有挂方法)1、玩家可以在hhp...
热点推荐!拱趴游戏破解器,po... 热点推荐!拱趴游戏破解器,pokemmo脚本辅助,普及教程(有挂攻略)是由北京得拱趴游戏破解器黑科技...
一分钟秒懂!aapoker免费... 一分钟秒懂!aapoker免费透视脚本,大菠萝789辅助器下载,实用技巧(有挂技巧);玩家必备必赢加...
今日头条!wepoker挂,h... 今日头条!wepoker挂,hhpoker底牌透视脚本,细节方法(有挂方法);玩家必备必赢加哟《13...
玩家交流!werplan透视挂... 玩家交流!werplan透视挂,werplan外挂,微扑克教程(有挂辅助);小薇(透视辅助)致您一封...
揭秘!wepoker怎么增加运... 揭秘!wepoker怎么增加运气,epoker底牌透视,揭秘教程(有挂神器);建议优先通过wepok...
今日百科!约局吧开挂,hhpo... 《今日百科!约局吧开挂,hhpoker辅助,扑克教程(有挂方法)》 约局吧开挂软件透明挂更新公告新增...
玩家实测!wepoker私人局... 玩家实测!wepoker私人局透视,hhpoker有后台操控吗,AI教程(有挂教程);hhpoker...
科技新动态!hhpoker真能... 科技新动态!hhpoker真能买到挂吗,wepoker正确养号方法,曝光教程(有挂透明);hhpok...