Reputation: 1507
SO ive been using the following tutorial to get a gps service going:
http://www.marioalmeida.eu/2014/02/21/how-to-do-android-ipc-using-messenger-to-a-remote-service/
I got it working and my GPS works fine and its all good. My problem is that I cant kill the service. I thought calling unbind on it would kill it but it didnt. I am using a wakelock to keep the service awake so it can record the GPS co-ordinates (its a location tracker). Then after I unbind I release the wakelock. I alos have a piece of code that checks if the service is running. Before I call unbind (this is where I release the wakelock too) it is but after I call unbind it is not.
The problem is in my service I have toast messages popping up so I know where the code is. Even after I kill the service these toast messages are still popping up.
Can anyone tell me how my service could still be running after I have unbound and checked that the service is not running? Im completely stumped
Upvotes: 0
Views: 68
Reputation: 73721
Unbinding a service does not stop a service. You can stop your service by simply calling stop service:
Intent i = new Intent(context,MyService.class)
stopService(i);
or you can use stopSelf()
inside your service class.
Upvotes: 2