Reputation: 155
I have a service:
[Service]
public class LocationService : Service, ILocationListener
{
....
public override StartCommandResult OnStartCommand(...)
{ return StartCommandResult.Sticky; }
}
Started in one of environment
new Task(() =>
{
Application.Context.StartService(new Intent(Application.Context, typeof(LocationService)));
}).Start();
How to stop this service from another place?
I tried to do this:
Application.Context.StopService(new Intent(Application.Context, typeof(LocationService)));
but it does not always work
Upvotes: 0
Views: 244
Reputation: 155
the answer was here:
Stop Location Listener in Android
In my case its call method StopLocationUpdates
[Service]
public class LocationService : Service, ILocationListener
{
....
public override StartCommandResult OnStartCommand(...)
{
return StartCommandResult.Sticky;
}
public void StopLocationUpdates()
{
LocManager.RemoveUpdates(this);
LocManager= null;
}
}
Upvotes: 0
Reputation: 3624
These possible duplicates might solve your issue:
android LocationListener not stopping GPS use
Sounds like the big thing is making sure nothing is still requesting location updates.
Upvotes: 1