简体   繁体   中英

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. 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. Run the following

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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