Exemplo n.º 1
0
 public void onActivityResult(int requestCode, int resultCode, Intent intent) {
   if (requestCode == INTENT_ID && resultCode == Activity.RESULT_OK) {
     Place place = PlacePicker.getPlace(intent, activity.getApplicationContext());
     for (ObjectListener<Place> placeListener : placeListeners) {
       placeListener.onTaken(place, 0);
     }
   }
 }
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (requestCode == Constants.PLACE_PICKER_REQUEST) {
     if (resultCode == RESULT_OK) {
       Place place = PlacePicker.getPlace(data, this);
       locationAddress = place.getAddress().toString();
       locationLat = Double.toString(place.getLatLng().latitude);
       locationLng = Double.toString(place.getLatLng().longitude);
       listPlaces();
     }
   }
 }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Check to see if the result is from our Place Picker intent
    if (requestCode == PLACE_PICKER_REQUEST) {
      // Make sure the request was successful
      if (resultCode == RESULT_OK) {
        Place place = PlacePicker.getPlace(data, this);
        String address = place.getAddress().toString();
        LatLng latLong = place.getLatLng();

        // If the provided place doesn't have an address, we'll form a display-friendly
        // string from the latlng values.
        if (TextUtils.isEmpty(address)) {
          address = String.format("(%.2f, %.2f)", latLong.latitude, latLong.longitude);
        }

        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(getString(R.string.pref_keys_location), address);

        // Also store the latitude and longitude so that we can use these to get a precise
        // result from our weather service. We cannot expect the weather service to
        // understand addresses that Google formats.
        editor.putFloat(getString(R.string.pref_location_latitude), (float) latLong.latitude);
        editor.putFloat(getString(R.string.pref_location_longitude), (float) latLong.longitude);
        editor.commit();

        /*Refresh The Preference*/
        // Tell the SyncAdapter that we've changed the location, so that we can update
        // our UI with new values. We need to do this manually because we are responding
        // to the PlacePicker widget result here instead of allowing the
        // LocationEditTextPreference to handle these changes and invoke our callbacks

        Preference locationPreference = findPreference(getString(R.string.pref_keys_location));
        locationPreference.setSummary(address);

        // Add attributions for our new PlacePicker location.
        if (mAttribution != null) {
          mAttribution.setVisibility(View.VISIBLE);
        } else {
          // For pre-Honeycomb devices, we cannot add a footer, so we will use a snackbar
          View rootView = findViewById(android.R.id.content);
          Snackbar.make(rootView, getString(R.string.attribution_text), Snackbar.LENGTH_LONG)
              .show();
        }

        Utility.resetLocationStatus(this);
        SunshineSyncAdapter.syncImmediately(this);
      }
    } else {
      super.onActivityResult(requestCode, resultCode, data);
    }
  }
Exemplo n.º 4
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == PLACE_PICKER_REQUEST && resultCode == Activity.RESULT_OK) {

      final Place place = PlacePicker.getPlace(data, this);
      final CharSequence name = place.getName();
      final CharSequence address = place.getAddress();
      String attributions = PlacePicker.getAttributions(data);
      if (attributions == null) {
        attributions = "";
      }

      // mName.setText(name);
      // mAddress.setText(address);
      // mAttributions.setText(Html.fromHtml(attributions));
      btnLocation.setText(address);
      btnLocation.setText("TTTTTTTTTTTTTTTTTTTTTTTTTTTTT");

    } else {
      super.onActivityResult(requestCode, resultCode, data);
    }
  }