Android : how to get the gender and age of the user?(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("users.account.name@gmail.com")
.build();
client.connect();
Person.Gender gender;
Person personProfile = Plus.PeopleApi.getCurrentPerson(client);
if (person.hasGender()) // it's not guaranteed
gender = person.getGender();
这篇关于Android:如何获取用户的性别和年龄?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android:如何获取用户的性别和年龄?


基础教程推荐
- Java Swing计时器未清除 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01