Share via


Geolocation.StartListeningForegroundAsync(GeolocationListeningRequest) Method

Definition

Starts listening to location updates using the LocationChanged event or the ListeningFailed event. Events may only sent when the app is in the foreground. Requests Permissions.LocationWhenInUse from the user.

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)

Parameters

request
GeolocationListeningRequest

The listening request parameters to use.

Returns

true when listening was started, or false when listening couldn't be started.

Exceptions

Thrown when request is null.

Thrown if listening is not supported on this platform.

Thrown if already listening and IsListeningForeground returns true.

Applies to