var bi = Settings.System.CanWrite(Android.App.Application.Context);
if (bi)
{
Console.WriteLine("IT HAS PERMISIONS`enter code here`");
}
else
{
Intent intent = new Intent(Android.Provider.Settings.ActionManageWriteSettings);
intent.SetData(Android.Net.Uri.Parse("package:" Android.App.Application.Context.PackageName));
StartActivity(intent);
Console.WriteLine("doesnt have permisions");
}
i get obviously direct in else execution block, but intent get null what is the problem? how i can grant permissions for write settings? i use xamarin with c# for android mobile AND ALREADY INSERT TO MANIFEST <uses-permission android:name="android.permission.WRITE_SETTINGS" />
CodePudding user response:
Intent intent = new Intent(Settings.ActionManageWriteSettings);
intent.SetData(Android.Net.Uri.Parse($"package:{Android.App.Application.Context.PackageName}"));
intent.AddFlags(ActivityFlags.NewTask);
Android.App.Application.Context.StartActivity(intent);
it works with this