I am creating an application which sends the location information to the server. But when the back or home button is clicked the application is stopped. Is there a way to make the application run continuously in background and sends data to the server ?
Asked
Active
Viewed 5,306 times
6
-
1and also check this http://stackoverflow.com/questions/8332819/best-practice-to-report-user-location-continuously – Ram kiran Pachigolla Sep 18 '12 at 05:41
-
check commens ware location poler its the best out there for poling the location to a server https://github.com/athulh/cwac-locpoll – Athul Harikumar Sep 18 '12 at 05:49
2 Answers
9
Use a background Service. Services are application components which can run in the background without user interaction. A good tutorial on Service
in android is from this.
You probably want to start the service on launch of your Activity
, or you can register for system broadcasts like BOOT_COMPLETE
to keep your service running from boot up.
However, keeping your service running throughout without user knowledge is a bad idea, and drains battery also. You probably want to wake up the service using AlarmManager
, do processing, schedule next restart, and exit.

Aswin Kumar
- 5,158
- 5
- 34
- 39
1
You need to run a Service class for your own application.
Refer docs for more information.

Vadim Kotov
- 8,084
- 8
- 48
- 62

Ram kiran Pachigolla
- 20,897
- 15
- 57
- 78