I want to get the current location from a background service at a particular time like 10 minutes, 20 minutes, etc. and it automatically is stopped by alarm manager after 2 hours, 4 hours, etc. At first the service starts by a button, then it works according to alarm manager as the time set like 10 minutes and by the same button the service completely stops.
I'm able to start the service by pressing the button at a particular time and getting location in activity.
Problems:
The service does not stop after providing location.
I want the service to start after 10 minutes, update the location and stop, then start again after 10 minutes and do the same work.
When pressing the button to stop the service completely, it's not stopping. When I press the button it stops, but at the time set in alarm manager it starts again.
Service does not stop automatically like after 2 hours, 6 hours... by alarm manager.
When mobile is in sleep mode, the service runs, but the location is not updated in activity TextView.