So i have an app i am working on and i need various permissions. I have these permissions in my AndroidManifest.xml and i am requesting them when i need them. But nothing happens when i call the ActivityCompat.RequestPermissions() method.
My test device is a OnePlus 3 running Android 7.1 API 25 here is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.henryapps.mortyfyingsoundboard" android:installLocation="internalOnly" android:versionCode="12" android:versionName="12">
<uses-sdk android:minSdkVersion="14" />
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application android:label="Mortyfying Sounboard">
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
</manifest>
and here is my method to check if i have the correct permissions and request them if i do not.
if (CheckSelfPermission(Manifest.Permission.WriteSettings) != Permission.Granted || CheckSelfPermission(Manifest.Permission.ChangeConfiguration) != Permission.Granted ||
CheckSelfPermission(Manifest.Permission.ModifyAudioSettings) != Permission.Granted || CheckSelfPermission(Manifest.Permission.WriteExternalStorage) != Permission.Granted)
{
string[] permissions =
{
Manifest.Permission.WriteSettings,
Manifest.Permission.ChangeConfiguration,
Manifest.Permission.ModifyAudioSettings,
Manifest.Permission.WriteExternalStorage,
Manifest.Permission.ReadExternalStorage,
};
ActivityCompat.RequestPermissions(this, permissions, 105);
if(CheckSelfPermission(Manifest.Permission.WriteSettings) != Permission.Granted || CheckSelfPermission(Manifest.Permission.ChangeConfiguration) != Permission.Granted ||
CheckSelfPermission(Manifest.Permission.ModifyAudioSettings) != Permission.Granted || CheckSelfPermission(Manifest.Permission.WriteExternalStorage) != Permission.Granted)
{
Toast toast = Toast.MakeText(this, "Request of permissions failed...", ToastLength.Short);
toast.Show();
}
}
I have been looking at examples of this for a week now and have had no luck in getting this working and am getting very frustrated. Being a newer Android developer (1 year now) it is difficult to make sense of what little documentation Xamarin provides on this.