问题描述
我已经在我的应用中实现了Google Play游戏服务。但是,当我在静默登录失败时调用交互式登录时,该应用会询问权限:
当我为我的帐户打开无提示登录时,它可以正常工作。但是,使用交互式登录时,会询问这些权限,并且用户需要按允许。
我希望它在选择帐户后登录并且不询问权限。
我的代码:
private void signIn() {
GoogleSignInoptions signInoptions = GoogleSignInoptions.DEFAULT_GAMES_SIGN_IN;
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(context);
if (GoogleSignIn.hasPermissions(account,signInoptions.getScopeArray())) {
// Already signed in.
// The signed in account is stored in the 'account' variable.
GoogleSignInAccount signedInAccount = account;
} else {
// Haven't been signed-in before. Try the silent sign-in first.
GoogleSignInClient signInClient = GoogleSignIn.getClient(context,signInoptions);
signInClient.silentSignIn().addOnCompleteListener(context,new OnCompleteListener<GoogleSignInAccount>() {
@Override
public void onComplete(@NonNull Task<GoogleSignInAccount> task) {
if (task.isSuccessful()) {
// The signed in account is stored in the task's result.
GoogleSignInAccount signedInAccount = task.getResult();
} else {
Intent intent = signInClient.getSignInIntent();
startActivityForResult(intent,RC_SIGN_IN);
// Player will need to sign-in explicitly using via UI.
// See [sign-in best
// practices](http://developers.google.com/games/services/checklist) for
// guidance on how and when to implement Interactive Sign-in,// and [Performing Interactive
// Sign-in](http://developers.google.com/games/services/android/signin#performing_interactive_sign-in)
// for details on how to implement
// Interactive Sign-in.
}
}
});
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)