Geolocation.StartListeningForegroundAsync(GeolocationListeningRequest) 方法

定義

使用 LocationChanged 事件或 ListeningFailed 事件開始接聽位置更新。 只有在應用程式位於前景時,才會傳送事件。 來自使用者的要求 Permissions.LocationWhenInUse

public:
 static System::Threading::Tasks::Task<bool> ^ StartListeningForegroundAsync(Microsoft::Maui::Devices::Sensors::GeolocationListeningRequest ^ request);
public static System.Threading.Tasks.Task<bool> StartListeningForegroundAsync (Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest request);
static member StartListeningForegroundAsync : Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest -> System.Threading.Tasks.Task<bool>
Public Shared Function StartListeningForegroundAsync (request As GeolocationListeningRequest) As Task(Of Boolean)

參數

request
GeolocationListeningRequest

要使用的接聽要求參數。

傳回

true 當接聽已啟動,或 false 無法啟動接聽時。

例外狀況

requestnull 時擲回。

如果這個平台不支援接聽,則會擲回 。

如果已經接聽 並 IsListeningForeground 傳回 , true則擲回 。

適用於