简体   繁体   English

如何在 android 应用中请求照片/媒体/文件权限

[英]How to ask for Photos/Media/Files permission in android app

enter image description here I want my app to ask for Photos/Media/Files permission since a third party library requires it, can anyone tell me which specific permission to ask for.在此处输入图像描述我希望我的应用程序请求照片/媒体/文件权限,因为第三方库需要它,任何人都可以告诉我要请求哪个特定权限。

Thanks谢谢

Files, photos and media are saved in storage.文件、照片和媒体保存在存储中。 Your android app will request permission in the relation of what it requires to do.您的 android 应用程序将根据它需要做的事情请求许可。 Add the permissions in your Manifest file.在您的清单文件中添加权限。

The permission you require is:您需要的权限是:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

If you want to save Files with your app too, request:如果您也想用您的应用程序保存文件,请请求:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Android versions from Marshmallow and above require runtime grant of permissions. Marshmallow 及更高版本的 Android 版本需要运行时授予权限。 Run the following运行以下

String[] PERMISSIONS = {
        Manifest.permission.WRITE_EXTERNAL_STORAGE,
        Manifest.permission.READ_EXTERNAL_STORAGE
};
ActivityCompat.requestPermissions(this,
PERMISSIONS,
PERMISSION_REQUEST_READ_FOLDERS);

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

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