0

我是android开发的新手。我正在开发移动应用程序。在这个应用程序中,需要用户国家,请帮助我,当用户通过谷歌帐户登录时如何获取用户国家。我浪费了更多的时间,但没有得到任何解决方案。

Scope myScope = new Scope("https://www.googleapis.com/auth/user.birthday.read");
    Scope myScope2 = new Scope(Scopes.PLUS_ME);
    Scope myScope3 = new Scope(Scopes.PROFILE); //get name and id

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestScopes(myScope, myScope2, myScope3)
            .requestEmail()
            .requestProfile()
            .requestEmail()
            .build();



mGoogleApiClient = new GoogleApiClient //this is the line of the error
                .Builder(this)
                .enableAutoManage(this,(GoogleApiClient.OnConnectionFailedListener) this)
                .addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
                    @Override
                    public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
                        Toast.makeText(getApplicationContext(),"La conexión alcliente api de Google ha fallado",Toast.LENGTH_LONG).show();
                    }
                })
                //.addApi(Plus.API)
                .addApi(Auth.GOOGLE_SIGN_IN_API,gso)
                .build();

 GoogleSignInAccount acct = result.getSignInAccount();
        System.out.println("Display Name:="+acct.getDisplayName());
        System.out.println("Display Name:="+acct.getEmail());
        System.out.println(""+ acct.getGivenName());
        System.out.println(""+acct.getFamilyName());
4

1 回答 1

-1

抱歉,我们将于 2019 年 4 月 2 日为消费者(个人)帐户关闭 Google+ 和登录 API

于 2019-02-03T14:57:54.550 回答