-2

When I go maps|settings|edit home or work I see my home & work address, cool!

Anybody know how to get that same information from the Android SDK? I am working on a maps app and would like to plot those to points of reference, with out asking the user for them again?

Thanks

TomHa
  • 3
  • 2

1 Answers1

0

You will need to use reverse geocoding to convert the latitude/longitude into an address. More info about geocoding can be found here.

Here is an example:

    Geocoder geocoder = new Geocoder(context, Locale.getDefault());   
    String result = null;
    try {
        List<Address> list = geocoder.getFromLocation(
                location.getLatitude(), location.getLongitude(), 1);
        if (list != null && list.size() > 0) {
            Address address = list.get(0);
            // sending back first address line and locality
            result = address.getAddressLine(0) + ", " + address.getLocality();
        }
    } catch (IOException e) {
        Log.e(TAG, "Impossible to connect to Geocoder", e);
    }
todd
  • 1,266
  • 1
  • 13
  • 20
  • The Geocoder is not quite what I need, at first. I need to get the default home and work address from the address book or where ever Google store it. Then I will use geoCoder to convert that address to lat/lon – TomHa Jun 07 '14 at 00:48