I am trying to solve a problem, my Xamarin App needs the camera in a View. when the App is opened, it requests the permissions (if the user grants the permissions, everything is fantastic), if the user rejects them, when entering the view I put a button to request the permissions again, but it does not work, the famous poster does not appear from android requesting access. and another strange thing is that if I close the App the permission request appears again -you only see the android message requesting permissions, my app is no longer visible and it is closed- Can someone guide me what may be happening
Button code:
private void BtnSolicitarAccesoCamara_OnClick(object sender, System.EventArgs e)
{
Task.Factory.StartNew(async () =>
{
if (Plugin.Permissions.CrossPermissions.IsSupported)
{
var result = await Plugin.Permissions.CrossPermissions.Current.CheckPermissionStatusAsync(Plugin.Permissions.Abstractions.Permission.Camera);
if (result != Plugin.Permissions.Abstractions.PermissionStatus.Granted)
{
var rp = await Plugin.Permissions.CrossPermissions.Current.RequestPermissionsAsync(Plugin.Permissions.Abstractions.Permission.Camera);
}
}
});
}
MainActivity
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] global::Android.Content.PM.Permission[] grantResults)
{
PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
global::ZXing.Net.Mobile.Android.PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
in your Activity's OnCreate method: "JMontemagno"
Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, bundle);