Monday, October 10, 2011

Re: [android-developers] Get GPS Location in a Broadcast Receiver.

On Mon, Oct 10, 2011 at 1:46 AM, shihab Shuvro <shihab.mi7@gmail.com> wrote:
> question 1. Is it possible to get GPS Location data in Broadcast
> receiver.?

No.

> 2.  Another alternative way i tried so far, use a service which
> invokes in Broadcast receiver. the service can get GPS data .but how i
> get it in Broadcast receiver ??

You don't.

When the BroadcastReceiver needs a GPS fix, it will need to call
startService() to have a Service register the listeners and run until
a GPS fix arrives or some timeout condition occurs (e.g., user is in
an underground facility and cannot get a GPS signal). At that point,
the service can:

-- unregister the location updates listener
-- do whatever work you needed to do with the GPS fix, probably on a
background thread
-- call stopSelf() to get rid of the service once the work is complete

If the BroadcastReceiver in question is one triggered by AlarmManager
and might be waking up the phone, you have the added complexity of
ensuring that the device will stay awake while all this is going on.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate