27

When in Google Inbox you go to snooze a message and select 'Pick place' it shows a list with your home and work address (from Google Now) populated as well as starred locations from your Google Maps profile. Other Google apps, like Keep also provide similar functionality.

I would like to implement this in my app but couldn't find the right API that exposes that information. Is that something that Google doesn't expose to 3rd parties (I guess there's room for abuse there)?

If not, how can this be implemented? What API has the data?

enter image description here

6
  • Google doesn't provide this information from their API...There is dew suggestion over here stackoverflow.com/questions/16177235/… you can try, but they wouldn't give you "Home" or "Work" address
    – Verma
    Commented Sep 8, 2015 at 22:41
  • I've seen that question. I understand there's no .getHomeLocation() and .getWorkLocation() anywhere and that's OK. But then Google Inbox does get those values from somewhere somehow. There must be a way. Commented Sep 9, 2015 at 8:28
  • @KrzysztofKozmic it is possible that Inbox uses a private API to access that information
    – Whymarrh
    Commented Sep 9, 2015 at 10:11
  • or that googleinbox does a call from "serverside" and the call is limited to "googleIPs" Commented Sep 9, 2015 at 10:28
  • The list somehow makes its way to my phone... Commented Sep 9, 2015 at 11:57

2 Answers 2

13
+200

Google Now utilizes analytics on your location data (on any and all devices signed into Google + location services enabled in your Google Account settings) to determine your home and work locations, unless you specifically set them.

The storage / retrieval of this data is not explicitly referenced anywhere that I have found in official Google documentation, but the schema in Google Now for this data is available here: Google Schema - Person

For any given person entity, a homeLocation and workLocation property exists with that data.

Alternatively (or in addition to), using Google's Plus Platform / Google Identity Platform, if you have an authenticated user, you can make an API call as described here (with examples) to get any of the specified fields for the current user (including currentLocation, organizations (including work) with addresses, if the user provided them).

A previous SO question that references using oAuth and raw Google Maps feed urls to pull the data exists, but the accepted answer is somewhat unclear and when I followed the links and attempted authenticated to test it out, I received 404 errors from all of them: Access locations in My Places of a particular account through Google Maps API

Also as in a Google Product Forums post here several years ago, a previous version of the Google Maps Data API allowed access to My Places, which is quintessentially exactly what you need, but it was deprecated and removed in 2013.

Finally, and this is the best approach in my opinion, and may be what Google uses (if it isn't declared to be Google Now), which is the Google Contacts API. A user exists in their own contact list, and the extensive API for Google Contacts allows you to get/set addresses with standard labels such as home or work for the user.

This is all detailed here: Google Contact Services - App Scripts

2
  • 1
    Thanks, that's some interesting pointers and avenues for investigation. I'll try experimenting with it over the weekend. For now I'll hold off accepting the answer in case someone provides a working POC sample. Commented Sep 16, 2015 at 23:04
  • Update: Google Now maintains it's own Home/Work locations that you can set manually, but that are automatically deduced based on other available information, first and foremost your Google Maps routes to/from locations during typical work hours, and which location you sleep at every night (though the actual logic behind what constitutes "sleeping at" is assumed by me). Commented May 24, 2016 at 18:21
1

Here is API for getting user's addresses

https://developers.google.com/android/reference/com/google/android/gms/identity/intents/Address

mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addApi(Address.API, new Address.AddressOptions())
        .build();
mGoogleApiClient.connect();
...
Address.requestUserAddress(mGoogleApiClient, UserAddressRequest.newBuilder().build(), REQUEST_CODE);


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    ...
    UserAddress address = UserAddress.fromIntent(data);
}

In dependencies

compile 'com.google.android.gms:play-services-identity:7.8.0'

There is no Home or Work addresses here, and I don't understand what kind of addresses it uses. But it seems that all user's addresses should be here.

1
  • 1
    UserAddress is always null. Trying on real device with valid user
    – iHS
    Commented Dec 21, 2016 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.