本文介绍了Android:如何获取用户的性别和年龄?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Android 应用,我想根据用户的性别和年龄自动设置.

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

获取用户年龄和性别的方法有哪些?(符合 Google Play 政策)

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

例如,有没有办法通过 Google Play Services 获取这些信息?

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

谢谢.

推荐答案

你应该使用 interface Person,您将拥有您需要了解的有关用户的所有信息.(通过getGender()getBirthday()(或getAgeRange())

例如使用 getGender(),你可以围绕这个做一些事情:

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

 GoogleApiClient client = new GoogleApiClient.Builder(this)
         .addApi(Plus.API)
         .addScope(Plus.SCOPE_PLUS_LOGIN)
         .setAccountName("[email protected]")
         .build();


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

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

这篇关于Android:如何获取用户的性别和年龄?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 12:33