Hello,
Welcome to our Microsoft Q&A platform!
Please do not use .Result
way to get the value. It will hang on your UI, you can get the value like following code with await
.
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private async void Button_Clicked(object sender, EventArgs e)
{
//Get the value from here.
var status= await AskRecordingPermission();
}
private async Task<bool> AskRecordingPermissionAsync()
{
var status = await Permissions.CheckStatusAsync<Permissions.Microphone>();
if (status != PermissionStatus.Granted)
status = await Permissions.RequestAsync<Permissions.Microphone>();
return status == PermissionStatus.Granted;
}
public async Task<bool> AskRecordingPermission()
{
var hasRecordingPermission = await AskRecordingPermissionAsync();
return hasRecordingPermission;
}
}
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.