xxxxxxxxxx
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
xxxxxxxxxx
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
xxxxxxxxxx
private final LocationListener mLocationListener = new LocationListener() {
@Override
public void onLocationChanged(final Location location) {
//your code here
}
};