You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.
If you are creating an issue for a BUG please fill out this information. If you are asking a question or requesting a feature you can delete the sections below.
Failure to fill out this information will result in this issue being closed. If you post a full stack trace in a bug it will be closed, please post it to http://gist.github.com and then post the link here.
Bug Information
Version Number of Plugin:6.0.1
Device Tested On:Android Version 9
Simulator Tested On:
Version of VS: 16.5.5
Version of Xamarin: Xamarin Version 16.5.00 and Xamarin.AndroidSDK 10.2
Versions of other things you are using:
Steps to reproduce the Behavior
I Install the recent plugin from NuGet 6.0.1 and xamarin. essentials version 1.5.3.2
Request calendar permission
Expected Behavior
Calendar permission set and application continues
Actual Behavior
I am getting below error and application crashes
System.MissingMethodException: 'Method not found: Android.App.Activity Xamarin.Essentials.Platform.get_CurrentActivity()'
Code snippet
async void ButtonPermission_OnClicked(object sender, EventArgs e)
{
if (busy)
return;
busy = true;
((Button)sender).IsEnabled = false;
var status = PermissionStatus.Unknown;
switch (((Button)sender).StyleId)
{
case "Calendar":
status = await CrossPermissions.Current.CheckPermissionStatusAsync<CalendarPermission>();
break;
case "Camera":
status = await CrossPermissions.Current.CheckPermissionStatusAsync<CameraPermission>();
break;
case "Settings":
CrossPermissions.Current.OpenAppSettings();
((Button)sender).IsEnabled = true;
busy = false;
return;
}
await DisplayAlert("Pre - Results", status.ToString(), "OK");
if (status != PermissionStatus.Granted)
{
switch (((Button)sender).StyleId)
{
case "Calendar":
status = await Utils.CheckPermissions(new CalendarPermission());
break;
case "Camera":
status = await Utils.CheckPermissions(new CameraPermission());
break;
}
await DisplayAlert("Results", status.ToString(), "OK");
}
busy = false;
((Button)sender).IsEnabled = true;
}
Utils Code:
public static async Task CheckPermissions(BasePermission permission)
{
var permissionStatus = await permission.CheckPermissionStatusAsync();
bool request = false;
if (permissionStatus == PermissionStatus.Denied)
{
if (Device.RuntimePlatform == Device.iOS)
{
var title = $"{permission} Permission";
var question = $"To use this plugin the {permission} permission is required. Please go into Settings and turn on {permission} for the app.";
var positive = "Settings";
var negative = "Maybe Later";
var task = Application.Current?.MainPage?.DisplayAlert(title, question, positive, negative);
if (task == null)
return permissionStatus;
var result = await task;
if (result)
{
CrossPermissions.Current.OpenAppSettings();
}
return permissionStatus;
}
request = true;
}
if (request || permissionStatus != PermissionStatus.Granted)
{
permissionStatus = await permission.RequestPermissionAsync();
if (permissionStatus != PermissionStatus.Granted)
{
var title = $"{permission} Permission";
var question = $"To use the plugin the {permission} permission is required.";
var positive = "Settings";
var negative = "Maybe Later";
var task = Application.Current?.MainPage?.DisplayAlert(title, question, positive, negative);
if (task == null)
return permissionStatus;
var result = await task;
if (result)
{
CrossPermissions.Current.OpenAppSettings();
}
return permissionStatus;
}
}
return permissionStatus;
}
If you are creating an issue for a BUG please fill out this information. If you are asking a question or requesting a feature you can delete the sections below.
Failure to fill out this information will result in this issue being closed. If you post a full stack trace in a bug it will be closed, please post it to http://gist.github.com and then post the link here.
Bug Information
Version Number of Plugin:6.0.1
Device Tested On:Android Version 9
Simulator Tested On:
Version of VS: 16.5.5
Version of Xamarin: Xamarin Version 16.5.00 and Xamarin.AndroidSDK 10.2
Versions of other things you are using:
Steps to reproduce the Behavior
I Install the recent plugin from NuGet 6.0.1 and xamarin. essentials version 1.5.3.2
Request calendar permission
Expected Behavior
Calendar permission set and application continues
Actual Behavior
I am getting below error and application crashes
System.MissingMethodException: 'Method not found: Android.App.Activity Xamarin.Essentials.Platform.get_CurrentActivity()'
Code snippet
async void ButtonPermission_OnClicked(object sender, EventArgs e)
{
if (busy)
return;
Utils Code:
public static async Task CheckPermissions(BasePermission permission)
{
var permissionStatus = await permission.CheckPermissionStatusAsync();
bool request = false;
if (permissionStatus == PermissionStatus.Denied)
{
if (Device.RuntimePlatform == Device.iOS)
{
Main activity Code
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
Screenshots
No
The text was updated successfully, but these errors were encountered: