好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > Windows 8 地理位置定位以及定位器狀態監測

Windows 8 地理位置定位以及定位器狀態監測

熱門標簽:誠信可靠的外呼系統 貝它電話機器人 濟南人工外呼系統代理 偃師市地圖標注 重慶智能電話機器人 和縣百度地圖標注店 青島呼叫中心外呼系統廠家 云南便宜電銷機器人廠家 現在的電話機器人好不好
在Windows8中,定位器不一定隨時可用,所以我們在使用定位器時最好先檢查一下定位器的狀態。
狀態可以從Geolocator中的屬性LocationStatus獲得。

定位器狀態是枚舉類型PositionStatus,共有6種狀態:Ready、Initializing、NoData、Disabled、NotInitialized、NotAvailable。
另外,有時還需要不斷檢測定位器的狀態,當定位器不可用時給用戶友好的提示,或做出其它的動作。Geolocator中有一個事件StatusChanged專門用來監測定位器狀態的改變。
下面來看代碼,總共只有一張頁面。
前臺XAML代碼如下

復制代碼
代碼如下:

Page
x:Class="Win8Location.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Win8Location"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
StackPanel Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
Button x:Name="btnCheckStatusChanged" Content="監測定位器狀態" Click="btnCheckStatusChanged_Click"/>
ScrollViewer>
TextBlock x:Name="txtMsg" TextWrapping="Wrap" FontSize="20"/>
/ScrollViewer>
/StackPanel>
/Page>

后臺cs代碼如下

復制代碼
代碼如下:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Devices.Geolocation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace Win8Location
{
public sealed partial class MainPage : Page
{
Geolocator geo = null;
public MainPage()
{
this.InitializeComponent();
}
private void btnCheckStatusChanged_Click(object sender, RoutedEventArgs e)
{
btnCheckStatusChanged.IsEnabled = false;
if (geo == null)
{
geo = new Geolocator();
}
txtMsg.Text = DateTime.Now.ToString() + ">定位器啟動,狀態為:" + geo.LocationStatus + "\n狀態描述:" + GetDescription(geo.LocationStatus);
geo.StatusChanged += geo_StatusChanged;
}
async void geo_StatusChanged(Geolocator sender, StatusChangedEventArgs args)
{
PositionStatus statu = args.Status;
string msg = "\n\n" + DateTime.Now.ToString() + ">定位器狀態改變為:" + statu.ToString();
msg += "\n狀態描述:" + GetDescription(statu);
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
txtMsg.Text += msg;
});
}
string GetDescription(PositionStatus statu)
{
string description = null;
switch (statu)
{
case PositionStatus.Ready:
description = "提供位置數據。";
break;
case PositionStatus.Initializing:
description = "位置提供程序正在初始化。如果 GPS 是位置數據源,并且視圖中的 GPS 接收器沒有所需的附屬數目來獲取準確的位置,則此為該狀態。";
break;
case PositionStatus.NoData:
description = "沒有來自任何位置提供程序的可用位置數據。在可從位置傳感器獲取數據之前,LocationStatus 將在應用程序調用 GetGeopositionAsync或注冊 PositionChanged 事件的事件處理程序時具有此值。數據可用后,LocationStatus 轉換為 Ready 狀態。";
break;
case PositionStatus.Disabled:
description = "位置提供程序已禁用。此狀態指示尚未被授予該用戶訪問位置的應用程序權限。";
break;
case PositionStatus.NotInitialized:
description = "檢索位置的操作尚未初始化。如果應用程序尚未調用 GetGeopositionAsync,或為 PositionChanged 事件注冊事件處理程序,則LocationStatus 可能具有此值。";
break;
case PositionStatus.NotAvailable:
description = "Windows 傳感器和位置平臺在此版本的 Windows 中不可用。";
break;
default:
description = "您的定位器太先進了,目前的技術無法得知其狀態:)";
break;
}
return description;
}
}
}

運行截圖如下:

標簽:甘肅 長治 潛江 拉薩 賀州 安順 松原 日照

巨人網絡通訊聲明:本文標題《Windows 8 地理位置定位以及定位器狀態監測》,本文關鍵詞  Windows,地理位置,定位,以及,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Windows 8 地理位置定位以及定位器狀態監測》相關的同類信息!
  • 本頁收集關于Windows 8 地理位置定位以及定位器狀態監測的相關信息資訊供網民參考!
  • 推薦文章