【发布时间】:2021-05-28 08:19:04
【问题描述】:
我尝试使用this教程在android中打开位置设置,但是在这个方法中:
public void OpenSettings()
{
}
我不知道在打开的位置设置中写什么。
我需要额外的库吗?
我写了这段代码:
public interface ILocSettings
{
void OpenSettings();
}
public void OpenSettings()
{
}
在GPS按钮方法中我写了这段代码:
var myAction = await DisplayAlert("Location", "Please Turn On Location", "OK", "CANCEL");
if (myAction)
{
if (Device.RuntimePlatform == global::Xamarin.Forms.Device.Android)
{
//DependencyService.Get<ISettingsService>().OpenSettings();
global::Xamarin.Forms.DependencyService.Get<ILocSettings>().OpenSettings();
}
else
{
_ = DisplayAlert("Device", "You are using some other shit", "YEP");
}
}
else
{
_ = DisplayAlert("Alert", "User Denied Permission", "OK");
}
所以消息出现了,但我不知道在 OpenSettings() 中写什么来打开手机上的 GPS 位置设置..
【问题讨论】: