I am trying to get city name from Google place picker. is there any way that we can get city name using place picker API. i know we can not simply get it from API by placing place.getCity();
Below is my code.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == REQUEST_PLACE_PICKER){
if(resultCode==RESULT_OK){
Place place = PlacePicker.getPlace(data,this);
final CharSequence name = place.getName();
final CharSequence address = place.getAddress();
final CharSequence phone = place.getPhoneNumber();
final String placeId = place.getId();
final LatLng latLng = place.getLatLng();
if(place.getLocale() != null) {
String aname = place.getLocale().toString();
areaname.setText(aname);
}
location.setText(address);
gname.setText(name);
latlon.setText(String.valueOf(latLng));
}
}
}
I don't want any null values in city. i read Geocoder
will give mostly null values.
Try using geocoder
Also you can try to call webservice and parse json result to get city. Just pass the lat/ lng you get from placepicker in below url. In the result administrative_area_level_2 represents the city