If you want the address components of the Place object (street, city, country, etc.) to be separated, you have two options.
- Use
Place.getLatLng() . Then, change the geocoding in latitude and longitude. - Sort the address.
Now parsing the address is not very simple. But reverse geocoding of latitude and longitude is inaccurate. I suggest parsing the address. There are good address parsing services, and some even check the address against address databases. (I suggest SmartyStreets . If you go to the SmartyStreets demo , select "Freeform address" from the drop-down list, and then see what information is returned when searching for the address.)
This is why reverse geocoding can be a bad solution. When you change the geocode, you select the latitude and longitude and algorithmically match it with the address. Some algorithms correspond to the latitude and longitude of the nearest valid address. In this case, the address may not be the address of your location. On the other hand, some algorithms approximate an address that matches latitude and longitude. In this case, the address may not be the real address. Another complication is mentioned in the documentation for getLatLng() :
The location is not necessarily the center of the place, or any specific point of entry or exit, but some arbitrary point within the geographical extent of the place.
Since latitude and longitude are arbitrary points in the geographical extent of a place, it is difficult to make reliable reverse geocoding algorithms.
But you may not like the accuracy. If so, and you need an address that is βclose enoughβ, reverse geocoding may be a good choice.
One more note:
static Place getPlace (intent intent, context context) This method is deprecated. Use getPlace (Context, Intent) instead.
I think you should replace your line:
Place place = PlacePicker.getPlace(data, getActivity());
with this:
Place place = PlacePicker.getPlace(getActivity(), data);
Full disclosure: I work for SmartyStreets.