我正在Android上构建一个步进跟踪器并与Google Fit成功集成。但是,我无法访问用户的Gmail地址。有人可以帮帮我吗?
要检索用户电子邮件地址,您必须实施Google Plus API,要使用plus API,请确保在build.grade
中添加播放服务依赖项。
compile com.google.android.gms:play-services-plus:15.0.1
之后,使用此代码段检索用户电子邮件地址。
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
String userEmail=currentPerson.getEmail();
}