Regis_AG Regis_AG - 1 year ago 125
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 ?


Answer Source

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();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download