Define the location receiver as follows:
LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { } public void onProviderDisabled(String provider) {} public void onProviderEnabled(String provider) {} public void onStatusChanged(String provider, int status, Bundle extras) {} };
Then:
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
source share