Share via


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引发 。

适用于