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/*”,该意图将打开系统的文件浏览器并让用户选择要打开的文件。

相关内容

热门资讯

透视辅助!xpoker辅助器,... 透视辅助!xpoker辅助器,大菠萝免费辅助器,学习教程(了解有挂)-哔哩哔哩1、让任何用户在无需大...
透视规律!智星德州辅助译码插件... 透视规律!智星德州辅助译码插件靠谱吗,德州hhpoker脚本,积累教程(发现有挂)-哔哩哔哩1、下载...
透视透视!hhpoker透视方... 透视透视!hhpoker透视方法,来玩德州破解器,办法教程(了解有挂)-哔哩哔哩1、该软件可以轻松地...
透视规律!we poker辅助... 透视规律!we poker辅助器下载,wepoker透视是真的吗,办法教程(果真有挂)-哔哩哔哩一、...
透视有挂!poker worl... 透视有挂!poker world辅助器,wepoker安装教程,步骤教程(有挂功能)-哔哩哔哩1、玩...
透视数据!wepokerplu... 透视数据!wepokerplus脚本,wepoker如何设置透视,课程教程(揭秘有挂)-哔哩哔哩we...
透视能赢!wepoker智能辅... 透视能赢!wepoker智能辅助插件,有哪些免费的wpk辅助码,总结教程(真是有挂)-哔哩哔哩1、该...
透视存在!wepoker私人局... 透视存在!wepoker私人局俱乐部,德普之星私人局透视,积累教程(证实有挂)-哔哩哔哩1、游戏颠覆...
透视好友!菠萝德普辅助器免费版... 透视好友!菠萝德普辅助器免费版在哪里,wepoker插件程序激活码,手筋教程(存在有挂)-哔哩哔哩1...
透视最新!pokermaste... 透视最新!pokermaster脚本,德州来玩辅助器,策略教程(真实有挂)-哔哩哔哩1、德州来玩辅助...