skip to Main Content

I’m making the use of read and write permission for accessing external storage and for getting the permission, I’m using the permission handler package

AndroidManifest.xml

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

For getting the permission from user

              var status = await Permission.storage.request();
                    if(status.isGranted){
                      Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (context) => const Home()));
                    } else if(status.isPermanentlyDenied){
                      openAppSettings();
                    }

The above permissions and code working perfectly for android versions till 12 but when it comes to android version 13, it is not working up, it just opens up the app setting instead of asking the permission

2

Answers


  1. For Android 13 or higher

    Menifest Permissions

    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
    <uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
    

    permission_handler (request)

    await Permission.photos.request();
    
    Login or Signup to reply.
  2. setp 1

    add permission android manifest

           <!-- Required only if your app targets Android 13 or higher. -->
    <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
     android:maxSdkVersion="33" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" 
       android:maxSdkVersion="33"  />
     <uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
     <uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
     <uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
    

    setp 2

     var status = await Permission.manageExternalStorageenter image description here.request();
                    if(status.isGranted){
                      Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (context) => const Home()));
                    } else if(status.isPermanentlyDenied){
                      openAppSettings();
                    }
    

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search