-
Is there a way to disable the GpsManager to auto start? I tried with manually adding the Gps and working with subscirptions instead of the GpsDelegate, but nothing worked yet. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
GPS will auto start if you request a background start on it. It will keep doing this until you stop the listener in your code.
You need to add some sort of sample of what you mean. I have no idea what you mean here or why it wouldn't work. |
Beta Was this translation helpful? Give feedback.
-
But it starts automatically on app start as the gps managers are a IShinyStartupTask, which should not be a problem when no currentSetting is set but magically its always set (idk from where) I tried this:
var request = new GpsRequest
{
BackgroundMode = GpsBackgroundMode.Realtime,
Accuracy = GpsAccuracy.Normal,
DistanceFilterMeters = 0,
};
var r = await this.gpsManager.RequestAccess(request).ConfigureAwait(false);
if (r == AccessState.Available)
{
this.gpsManager.WhenReading().SubscribeAsync(this.HandleLocationChangeAsync);
try
{
await this.gpsManager.StartListener(request).ConfigureAwait(false);
}
catch (Exception e)
{
Console.WriteLine(e);
}
} This works, but also when just starting the app without the Listener started. |
Beta Was this translation helpful? Give feedback.
-
I use v3.3.4. This is my delegate public partial class MyGpsDelegate : GpsDelegate
{
public MyGpsDelegate(ILogger<MyGpsDelegate> logger)
: base(logger)
{
this.MinimumDistance = Distance.FromMeters(0);
this.MinimumTime = TimeSpan.FromSeconds(15);
}
/// <inheritdoc />
protected override Task OnGpsReading(GpsReading reading)
{
Console.WriteLine("ON Gps reading! {0} {1}", reading.Position.Latitude, reading.Position.Longitude);
return Task.CompletedTask;
}
} It doesn't work no matter if i use background mode or not. |
Beta Was this translation helpful? Give feedback.
This request says that GPS should run in the background.
This call
Will make it run automatically if the app is swiped away and then restarted until you call IGpsManager.StopListener
Running your GpsRequest with backgroundmode and realtime arg is not right and should cause an error. If you don't want GPS to run in the background, you should just use GpsBackgroundMode.None. V3 doesn't auto start if those values aren't set and…