Thanks Mark...

On Apr 2, 3:52 pm, Mark Murphy <[email protected]> wrote:
> Anna PS wrote:
> > But - is it possible to get a location fix from within an
> > IntentService?
>
> It would be difficult, because IntentServices want to shut down as soon
> as onHandleIntent() completes (if there are no more Intents to be
> processed). Since the location lookup is asynchronous, you would have
> problems.
>
> This is a case where you may need to implement a regular Service, using
> an AsyncTask for the upload portion, and then call stopSelf() when you
> are done.

What I've actually done is call a normal Activity, add a location
listener, show a notification, and check for location accuracy within
onLocationChanged. Once the desired accuracy is reached, I start an
IntentService from within onLocationChanged, and then remove the
location listener.

The location listener keeps going in the background, so it doesn't
matter if the user switches away. It seems to work, though I'd welcome
any advice on how it might cause problems.

> > This must be a common problem, so it would be good to get a clear
> > answer.
>
> Oh, if only all common problems had clear answers. There would be no
> hunger, no disease, and no receding hairlines. :-)

Ha! :))

-- 
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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to