public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
}
I want to call here:
var status = await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>();
How to do it?
call it in OnAppearing
public override async void OnAppearing()
{
var status = await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>();
}
If you don't want to call this in the OnAppearing() method and specifically in the contructor, you can do this (watch out for possible thread blocking though):
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
// watch out for possible thread blocking!
Task.Run(async() =>
{
await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>();
});
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.