예제 #1
0
  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();
  }
예제 #2
0
  private void onLocationUpdate(Address address) {
    TextView lblCurrentLocation = (TextView) getActivity().findViewById(R.id.lblCurrentLocation);

    if (address != null) {
      _address = address;
      lblCurrentLocation.setText(LocationHelper.getLocationName(_address, true));

      _weatherInfoHelper = new WeatherInfoHelper(getString(R.string.webServiceBaseUrl), _address);
      _weatherInfoHelper.registerListener(this);
    } else {
      lblCurrentLocation.setText(getString(R.string.noLocation));
      setReloadingState(false);
    }
  }