Jimmy Shah
Jimmy Shah

Reputation: 79

Android Application: application should launch as service

I am developing an application that can send location details to a web service in .net I am able to generate co-ordinates and send it to webservice. The problem is I want the user to enter username when he starts the application for the first time and store in SharedPreference (I am able to do that) But after that I want the application to work as a service as it doesnt have any GUI. Please help me with this.

Upvotes: 1

Views: 136

Answers (1)

Neil Townsend
Neil Townsend

Reputation: 6084

You need two things:

  1. A service which runs in the background and is started on boot. This will do the core work. A basic service tutorial is here: http://techblogon.com/simple-android-service-example-code-description-start-stop-service/ Once you've got that running, you will need to add your location sending code to it's startup routine, and then configure it to call it self on a regular basis (say using Alarm Manager). There are plenty of tutorials out there on doing this kind of thing.

  2. An (standard) activity which accepts the user information. This will run when the user "runs" the application and should also start the service. You can configure this activity to have the user feel you wish.

Upvotes: 2

Related Questions