gpt4 book ai didi

android - 应用程序如何在没有 root 的情况下访问 Android 6.0(API 级别 23)中 USB OTG 存储上的文件?

转载 作者:IT老高 更新时间:2023-10-28 23:13:11 25 4
gpt4 key购买 nike

Android 6.0 开发者预览版(API 级别 23)可以在没有任何额外应用程序的情况下本地安装外部可移动 USB OTG 存储设备(更多信息请参阅:https://www.androidpolice.com/2015/05/28/android-m-feature-spotlight-external-storage-can-be-adopted-as-true-internal-storage-or-accessed-normally-with-no-additional-apps/)。

当用户连接 USB OTG 存储时,它会显示在系统存储菜单中,并且可以通过内置文件管理器访问。用户可以使用新的内置文件管理器访问 USB OTG 外部存储上的所有文件,无需 root 权限。

当我将 USB OTG 存储连接到我的 Android 设备时,它安装在 /storage/A03E-1DF5/mnt/media_rw/A03E-1DF5,但访问此文件夹需要 root 权限。

我正在开发 Android 媒体播放器应用程序。

是否可以以及如何在我的应用程序中访问 Android 6.0 上 USB OTG 存储上的文件,例如没有 root 权限的内置文件管理器?

附:我已经在我的应用程序中使用了 checkSelfPermissionrequestPermissions 函数,并且我的应用程序已经具有 android.permission.READ_EXTERNAL_STORAGEandroid.permission.WRITE_EXTERNAL_STORAGE (更多信息请参见:https://www.androidpolice.com/2015/07/15/android-m-feature-spotlight-apps-now-need-your-permission-to-read-and-write-to-external-storage/),但看起来这些权限只影响内部存储(MicroSD),而对于 USB OTG 则没有这种细粒度的权限。

最佳答案

从 Android 6 开始,根据 USB Media Support文档,Storage Access Framework似乎是唯一可用的机制:

In Android 6.0, any device that is not adopted is considered portable. […] Third-party apps must go through the Storage Access Framework to interact with files on portable storage; direct access is explicitly blocked for privacy and security reasons.

关于android - 应用程序如何在没有 root 的情况下访问 Android 6.0(API 级别 23)中 USB OTG 存储上的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32201169/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com