无法找到api GoogleSignIn.silentSignIn

时间:2017-11-28 19:15:55

标签: google-signin

我正在按照here找到的教程。但我无法找到文档中提到的api: GoogleSignIn.silentSignIn()

是弃用还是删除?

如果是,请有人纠正指南。

2 个答案:

答案 0 :(得分:3)

示例中的错误,该方法在Auth.GoogleSignInApi中声明。请参阅the references

答案 1 :(得分:3)

正确的方法

        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.server_client_id))
            .requestEmail()
            .build();
    GoogleSignInClient googleSignInClient = GoogleSignIn.getClient(this, gso);
    googleSignInClient.silentSignIn().addOnCompleteListener(this, new OnCompleteListener<GoogleSignInAccount>() {
        @Override
        public void onComplete(@NonNull Task<GoogleSignInAccount> task) {
            handleSignInResult(task);
        }
    });