How to Request manage_external_storage Permission in Xamarin.Android

Please I am looking for a way to request (Manage_External_Storage) Permission in Xamarin.Android because i need this permission in my app after android 11

Upvotes: 1

Views: 1617

Answers (1)

Liyun Zhang - MSFT
Liyun Zhang - MSFT

Reputation: 14204

This permission is about accessing all the files. At first, the permission should be added to the AndroidManifest.xms.And then you can use the following code to request the permission. In addition, you can request the write and read external peimissoin and add them in the Manifest.xml.

 if (!Android.OS.Environment.IsExternalStorageManager)
             {
                 Intent intent = new Intent();
                 intent.SetAction(Android.Provider.Settings.ActionManageAppAllFilesAccessPermission);
                 Android.Net.Uri uri = Android.Net.Uri.FromParts("package", this.PackageName, null);
                 intent.SetData(uri);
                 StartActivity(intent);
             }

Upvotes: 1

Related Questions