android - 如何通过在我的应用程序中集成 google plus 获取完整配置文件?

标签 android google-plus-signin

嗨,我正在尝试在我的应用程序中使用 google plus 唱歌,登录后获取用户完整个人资料生日、名字、姓氏、性别、联系电话等

private void getProfileInformation() {
    try {
        if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
            Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
            String personName = currentPerson.getDisplayName();
            String personID = currentPerson.getId();
            String AgeRange  = String.valueOf(currentPerson.getAgeRange());


            String Place = String.valueOf(currentPerson.getPlacesLived());
            String personNamef = String.valueOf(currentPerson.getName()); //Gives First Name and Last Name in Json formay
            int personGender = currentPerson.getGender(); //Gives Gender in int 0:Male, 1:Female
            String personCircle = String.valueOf(currentPerson.getCircledByCount());
            String personPhotoUrl = currentPerson.getImage().getUrl();
            String personGooglePlusProfile = currentPerson.getUrl();
            String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
            if(personGender == 0){
                gen = "Male";
            }
            if(personGender == 1){
                gen = "Female";
            }
            if(personGender == 2){
                gen = "Other";
            }


            Log.e(TAG, "First Name: " + personNamef + ", plusProfile: "
                    + personGooglePlusProfile + ", ID: " + personID
                    + ", AgeRange: " + AgeRange +
                     ", CircledByCount: " + personCircle +

                    ", PlacesLived: " + Place);

            txtName.setText(personName);
            txtEmail.setText(email);
            txtGender.setText(gen);


            // by default the profile url gives 50x50 px image only
            // we can replace the value with whatever dimension we want by
            // replacing sz=X
            personPhotoUrl = personPhotoUrl.substring(0,
                    personPhotoUrl.length() - 2)
                    + PROFILE_PIC_SIZE;

            new LoadProfileImage(imgProfilePic).execute(personPhotoUrl);

        } else {
            Toast.makeText(getApplicationContext(),
                    "Person information is null", Toast.LENGTH_LONG).show();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

我在这里没有完整的个人资料,请帮助我..提前致谢

最佳答案

Google plus API 不提供任何获取用户联系电话的方法,即使他们已经公开了!! 更多详情请访问Retrieve phone number from a signed in user profile from google plus login in android

关于android - 如何通过在我的应用程序中集成 google plus 获取完整配置文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30679382/

相关文章:

java - Here-API:PDE 请求返回 GeoboundingBox 之外的 POI

ios - 如何更改 Google Plus 登录按钮的标题?

android - 切换谷歌登录按钮android

android - GoogleApiClient 有一个可选的 Plus.API,并且没有连接到带有 Play Services 8.3 中引入的新 Google 标志的 Plus

android - 在没有开发服务器的设备上构建和安装未签名的 apk?

javascript - Phonegap 应用程序文本出现后立即消失。我该如何调试?

java - Java 类之间的通信

android - 带有复选框的 ListView 中的 IndexOutOfBoundsException

cordova - Ionic Native GooglePlus 登录失败,没有任何错误

javascript - 在 JavaScript 不起作用的情况下启动 Google+ 登录流程