Regis_AG Regis_AG - 4 months ago 48
Java Question

Android : how to get the gender and age of the user?

I have got an Android app that I want to auto-setup according the gender and age of the user.

What are the different ways to get the age and the gender of a user ? (which are Google Play policy compliant)

For example, is there a way to get these information through Google Play Services ?



You should use the interface Person, you'll have everything you need to know about the user. (through getGender() and getBirthday() (Or getAgeRange())

Edit : For using for example let's say getGender(), you would do something around this :

 GoogleApiClient client = new GoogleApiClient.Builder(this)

Person.Gender gender;
Person personProfile = Plus.PeopleApi.getCurrentPerson(client);

if (person.hasGender()) // it's not guaranteed
          gender = person.getGender();