如何可以访问到位置服务API禁止访问被禁止?到位置服务API
我没有收到来自微软开发中心一封信,信中包含此提示:
您的应用程序必须提供应用程序内设置,允许用户启用 和禁用和使用位置的应用程序的访问从位置 服务API。
任何人都可以提供我如何去这样做进一步的帮助?
如何可以访问到位置服务API禁止访问被禁止?到位置服务API
我没有收到来自微软开发中心一封信,信中包含此提示:
您的应用程序必须提供应用程序内设置,允许用户启用 和禁用和使用位置的应用程序的访问从位置 服务API。
任何人都可以提供我如何去这样做进一步的帮助?
请问您的应用程序使用位置服务,你需要有禁用它的能力,或者你在一般要求?
如果它是第一个然后就停止收集数据,并在您的应用程序禁用它。如果是第二个,然后进入WPmanifest和MainPage.xaml中InitializeComponent();
后立即取消其
粘贴此代码。您必须按此行添加对IsolatedStorage的引用using System.IO.IsolatedStorage;
。
if (IsolatedStorageSettings.ApplicationSettings.Contains("LocationConsent"))
{
return;
}
else
{
MessageBoxResult result = MessageBox.Show("Allow this app to access your location?", "Location", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
IsolatedStorageSettings.ApplicationSettings["LocationConsent"] = true;
}
else
{
IsolatedStorageSettings.ApplicationSettings["LocationConsent"] = false;
}
IsolatedStorageSettings.ApplicationSettings.Save();
}
还创建了ToggleSwitch它具有以下代码Settings.xaml页:
if (IsolatedStorageSettings.ApplicationSettings.Contains("LocationConsent"))
{
if ((bool)IsolatedStorageSettings.ApplicationSettings["LocationConsent"] == true)
{
locationSwitch.IsChecked = true;
}
else
{
locationSwitch.IsChecked = false;
}
}
else
{
MessageBoxResult result = MessageBox.Show("Allow this app to access your location?", "Location", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
IsolatedStorageSettings.ApplicationSettings["LocationConsent"] = true;
}
else
{
IsolatedStorageSettings.ApplicationSettings["LocationConsent"] = false;
}
IsolatedStorageSettings.ApplicationSettings.Save();
}
private void locationSwitch_Checked(object sender, RoutedEventArgs e)
{
if (IsolatedStorageSettings.ApplicationSettings.Contains("LocationConsent"))
{
IsolatedStorageSettings.ApplicationSettings["LocationConsent"] = true;
IsolatedStorageSettings.ApplicationSettings.Save();
}
}
private void locationSwitch_Unchecked(object sender, RoutedEventArgs e)
{
if (IsolatedStorageSettings.ApplicationSettings.Contains("LocationConsent"))
{
IsolatedStorageSettings.ApplicationSettings["LocationConsent"] = false;
IsolatedStorageSettings.ApplicationSettings.Save();
}
}
,并且使用的位置/ GPS数据包括下面的代码页:
if ((bool)IsolatedStorageSettings.ApplicationSettings["LocationConsent"] == true)
{
//Do Something
}
else
{
MessageBox.Show("Please enable location services to use this feature. You can turn it on from Settings.");
}
这必将帮助。我使用相同的。不要给予好评,并标记为答案,如果这可以帮助您太:)