JamieB
JamieB

Reputation: 923

What type of background service?

I'd like to get the location of the device and transmit it to a database every x minutes/hours depending on what the user chooses, initially the service isn't going to be needed until the user has logged in and chosen to run it in the background.

Would I use the AlarmManager for this or should I focus on a simple service that uses gps and toggles it when done?

Upvotes: 1

Views: 65

Answers (1)

MDMalik
MDMalik

Reputation: 4001

You need to do 3 different task.

A) Declare you service which basically is the Java file which gets the location and sends to they server.

B) After your user has logged in and now you need to start the GPS service you need to call this code

startService(new Intent(this, UpdaterServiceManager.class));

C) Make sure you have declared you service in AndroidManifest.xml

<service android:enabled="true" android:name=".services.UpdaterServiceManager" />

D) Stopping the Service where ever you want

 stopService(new Intent(this,UpdaterServiceManager.class));

Upvotes: 1

Related Questions