KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am new to android. I want to get GPS Location in a broadcast receiver but it shows an error. My code is : public void onReceive(Context context, Intent intent) { LocationManager locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // errors 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()); } Questions : Is it possible to get GPS Location data in Broadcast receiver? Another alternative way I tried so far was to use a service which is invoked by the Broadcast receiver. The service can get GPS data, but how can I get it in the Broadcast receiver?
Tags (comma-separated)
Save Edits
Cancel