Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Essentials/src/Geolocation/Geolocation.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public async Task<bool> StartListeningForegroundAsync(GeolocationListeningReques
if (listeningProviders.Count == 0)
listeningProviders.Add(providerInfo.Provider);

var continuousListener = new ContinuousLocationListener(LocationManager, providerInfo.Accuracy, listeningProviders);
continuousListener = new ContinuousLocationListener(LocationManager, providerInfo.Accuracy, listeningProviders);
continuousListener.LocationHandler = HandleLocation;
continuousListener.ErrorHandler = HandleError;

Expand Down
20 changes: 20 additions & 0 deletions src/Essentials/test/DeviceTests/Tests/Geolocation_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,25 @@ await MainThread.InvokeOnMainThreadAsync(async () =>
Assert.True(location.Timestamp < DateTimeOffset.UtcNow);
Assert.True(location.Timestamp > DateTimeOffset.UtcNow.Subtract(TimeSpan.FromDays(1)));
}

[Fact]
[Trait(Traits.InteractionType, Traits.InteractionTypes.Human)]
public async Task Geolocation_IsListeningForeground()
{
await MainThread.InvokeOnMainThreadAsync(async () =>
{
await Permissions.RequestAsync<Permissions.LocationWhenInUse>();
});

var request = new GeolocationListeningRequest(GeolocationAccuracy.Best);
request.DesiredAccuracy = GeolocationAccuracy.Low;
request.MinimumTime = TimeSpan.FromSeconds(5);

bool hasServiceStarted = await Geolocation.StartListeningForegroundAsync(request);

bool isListeningForeground = Geolocation.IsListeningForeground;

Assert.Equal(hasServiceStarted, isListeningForeground);
}
}
}