When you use startService() your service will remain running until 
stopSelf() or stopService() is called.

However, keep in mind that Android will eventually keep your process as the 
user has navigated away from the app so you can never guarantee to receive 
continuous location updates.

Another "crappy" way to do is to use startForeground() (might be 
setForeground, don't rmbr) which will include a notification icon always 
for the user. This will give you better chances to "survive" as a process 
but its STILL not guaranteed. Plus you will also annoy your user by having 
the icon always on his notification bar.

You need something smarter. As suggested you could attempt to wake up a 
service every 5 minutes using the AlarmManager to check for the latest 
location. Perhaps a tier based system, try WiFi, Cellular and then GPS.

Also check out PassiveLocationReceiver which will allow you to retrieve 
location updates when other apps ask them (e.g. Maps) so you get updated.

This is not an easy task on Android to get right.

On Wednesday, August 1, 2012 8:32:52 AM UTC-7, Kristopher Micinski wrote:
>
> That's not really a good idea either, it's not clear what the OP wants 
> to do within the service. 
>
> Typically you do something like set up a call back to receive location 
> updates or something similar... 
>
> kris 
>
> On Wed, Aug 1, 2012 at 11:12 AM, Gabriel Augusto 
> <[email protected]> wrote: 
> > A Service running in background every time must end with the battery or 
> be 
> > killed by the os. Make a Service that run, do your work and see 
> AlarmManager 
> > to start the Service again. 
> > 
> > 
> > 2012/8/1 bob <[email protected]> 
> >> 
> >> Maybe look at this? 
> >> 
> >> http://developer.android.com/reference/android/app/Service.html 
> >> 
> >> 
> >> On Monday, July 30, 2012 1:44:39 AM UTC-5, Vijay Krishnan wrote: 
> >>> 
> >>> Hi all, 
> >>>          In my case,i want to update the user latitude and longitude 
> in 
> >>> background when he is out of the application. 
> >>> 
> >>> Thanks, 
> >>> vijay.k 
> >> 
> >> -- 
> >> You received this message because you are subscribed to the Google 
> >> Groups "Android Developers" group. 
> >> To post to this group, send email to 
> [email protected] 
> >> To unsubscribe from this group, send email to 
> >> [email protected] 
> >> For more options, visit this group at 
> >> http://groups.google.com/group/android-developers?hl=en 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Android Developers" group. 
> > To post to this group, send email to [email protected] 
> > To unsubscribe from this group, send email to 
> > [email protected] 
> > For more options, visit this group at 
> > http://groups.google.com/group/android-developers?hl=en 
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to