private void getLocationByGpsOrNetwork() { LocationResult locationResult = new LocationResult() { @Override public void gotLocation(Location location) { LocationGeocoderTask locationGeocoderTask = new LocationGeocoderTask(getActivity()) { @Override protected void onPostExecute(Address result) { onLocationUpdate(result); } }; locationGeocoderTask.execute(location); } }; LocationHelper locationHelper = new LocationHelper(getActivity(), locationResult); locationHelper.getCurrentLocation(); }