Java Code Examples for com.google.android.gms.location.places.Place#getAddress()
The following examples show how to use
com.google.android.gms.location.places.Place#getAddress() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
private void displayPlace( Place place ) { if( place == null ) return; String content = ""; if( !TextUtils.isEmpty( place.getName() ) ) { content += "Name: " + place.getName() + "\n"; } if( !TextUtils.isEmpty( place.getAddress() ) ) { content += "Address: " + place.getAddress() + "\n"; } if( !TextUtils.isEmpty( place.getPhoneNumber() ) ) { content += "Phone: " + place.getPhoneNumber(); } mTextView.setText( content ); }
Example 2
Source File: PlacePickerFragment.java From android-play-places with Apache License 2.0 | 4 votes |
/** * Extracts data from PlacePicker result. * This method is called when an Intent has been started by calling * {@link #startActivityForResult(android.content.Intent, int)}. The Intent for the * {@link com.google.android.gms.location.places.ui.PlacePicker} is started with * {@link #REQUEST_PLACE_PICKER} request code. When a result with this request code is received * in this method, its data is extracted by converting the Intent data to a {@link Place} * through the * {@link com.google.android.gms.location.places.ui.PlacePicker#getPlace(android.content.Intent, * android.content.Context)} call. * * @param requestCode * @param resultCode * @param data */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { // BEGIN_INCLUDE(activity_result) if (requestCode == REQUEST_PLACE_PICKER) { // This result is from the PlacePicker dialog. // Enable the picker option showPickAction(true); if (resultCode == Activity.RESULT_OK) { /* User has picked a place, extract data. Data is extracted from the returned intent by retrieving a Place object from the PlacePicker. */ final Place place = PlacePicker.getPlace(data, getActivity()); /* A Place object contains details about that place, such as its name, address and phone number. Extract the name, address, phone number, place ID and place types. */ final CharSequence name = place.getName(); final CharSequence address = place.getAddress(); final CharSequence phone = place.getPhoneNumber(); final String placeId = place.getId(); String attribution = PlacePicker.getAttributions(data); if(attribution == null){ attribution = ""; } // Update data on card. getCardStream().getCard(CARD_DETAIL) .setTitle(name.toString()) .setDescription(getString(R.string.detail_text, placeId, address, phone, attribution)); // Print data to debug log Log.d(TAG, "Place selected: " + placeId + " (" + name.toString() + ")"); // Show the card. getCardStream().showCard(CARD_DETAIL); } else { // User has not selected a place, hide the card. getCardStream().hideCard(CARD_DETAIL); } } else { super.onActivityResult(requestCode, resultCode, data); } // END_INCLUDE(activity_result) }