Android Google帐户未登录
OnActivityResultAndroid Google帐户未登录,android,google-signin,google-play-games,Android,Google Signin,Google Play Games,OnActivityResult if (requestCode == RC_SIGN_IN) { Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data); try { GoogleSignInAccount account =
if (requestCode == RC_SIGN_IN) {
Task<GoogleSignInAccount> task =
GoogleSignIn.getSignedInAccountFromIntent(data);
try {
GoogleSignInAccount account = task.getResult(ApiException.class);
onConnected(account);
new AlertDialog.Builder(this)
.setMessage("All ok")
.setNeutralButton(android.R.string.ok, null)
.show();
} catch (ApiException apiException) {
String message = apiException.getMessage();
if (message == null || message.isEmpty()) {
message = "Error";
}
onDisconnected();
new AlertDialog.Builder(this)
.setMessage(message)
.setNeutralButton(android.R.string.ok, null)
.show();
}
}
静默登录
private void signInSilently() {
Log.d("123", "signInSilently()");
mGoogleSignInClient.silentSignIn().addOnCompleteListener(this,
new OnCompleteListener<GoogleSignInAccount>() {
@Override
public void onComplete(@NonNull Task<GoogleSignInAccount> task) {
if (task.isSuccessful()) {
Log.d("123", "signInSilently(): success");
onConnected(task.getResult());
} else {
Log.d("123", "signInSilently(): failure", task.getException());
onDisconnected();
}
}
});
}
当我点击“授权”按钮时,我可以注册一个帐户,但是注册后产生了一个错误4:,我查看了文档,没有找到这意味着什么,我可能只是瞎了眼。帮助穷人如何解决它以及它是什么我将版本代码更新为最新版本,并将游戏机加载到关闭的alpha访问中,一切正常您能提供错误吗?我了解到该错误被称为需要登录,但这对我帮助不大。去哪里报案?同样的事情也发生在我身上。你解决了吗?是的,在我的例子中,我的版本代码过时了,我没有考虑过。我更新了版本代码,并填写了游戏控制台的alpha关闭访问权限,一切都解决了!
private void signInSilently() {
Log.d("123", "signInSilently()");
mGoogleSignInClient.silentSignIn().addOnCompleteListener(this,
new OnCompleteListener<GoogleSignInAccount>() {
@Override
public void onComplete(@NonNull Task<GoogleSignInAccount> task) {
if (task.isSuccessful()) {
Log.d("123", "signInSilently(): success");
onConnected(task.getResult());
} else {
Log.d("123", "signInSilently(): failure", task.getException());
onDisconnected();
}
}
});
}
mGoogleSignInClient = GoogleSignIn.getClient(this,
new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN).build());