I am developing an app, where I am just finding an address based on a search, based on search I got the address latitude longitude and place Id, but I need one more thing -- Phone number of that address. When I read the Places API tuitorial it is return by getPhoneNumber()
, but I couldn't find any proper tutorial for this, can anyone help me to find a tutorial for getting the phone number of an address.
Asked
Active
Viewed 473 times
-1

Vadim Kotov
- 8,084
- 8
- 48
- 62

Jocheved
- 1,125
- 3
- 15
- 32
-
google also provides temporary googlePlaceId for random lat, lng or address. you can get phone number of a place only if it is lised as a place in google maps (and if the place has an available phone number). – rajeswari ratala Apr 13 '16 at 10:04
-
@ Rajeshwari... can u give more details.. – Jocheved Apr 13 '16 at 10:19
-
I have used google place picker mostly. it shows places on map which places are listed. if you select a place that is listed, the activity will return details of the place. for example, if the selected place id a restaurant, you will receive opening hours, rating etc. but if you pin a random lat, lng the activity will return temporary google place id (which does not have any details as the place is not listed). – rajeswari ratala Apr 13 '16 at 10:46
1 Answers
0
if place has an available phone number
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Place place = PlaceAutocomplete.getPlace(this, data);
Log.i("Register", "Place: " + place.getName());
// get phone number form place object
String phonenumber = place.getPhoneNumber().toString();
LatLng latLng = place.getLatLng();
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status status = PlaceAutocomplete.getStatus(this, data);
// TODO: Handle the error.
Log.i("Register", status.getStatusMessage());
} else if (resultCode == RESULT_CANCELED) {
// The user canceled the operation.
}
}
}

Pratap
- 591
- 8
- 25