Sunday, October 9, 2011

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

hi, i m new in android.

i want to get GPS Loction in a broadcast receiver .

but it shows error .my code is here.

public void onReceive(Context context, Intent intent) {

LocationManager locManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
// erros in getSystemService method
LocationListener locListener = new MyLocationListener();
locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
locListener);

Location loc=
locManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
Log.d(" **location**", " location"+loc.getLatitude());

}

question 1. Is it possible to get GPS Location data in Broadcast
receiver.?
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 ??

Plz help me.

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