问题描述
在我发布应用后,玩游戏登录在我的应用中不起作用。我无法理解问题出在哪里 这些是为登录和成就和排行榜创建的功能。我认为问题与 OAuth 服务器有关,但我不知道该怎么做。Somone 能解释一下吗。
private fun startSignInIntent() {
val signInClient = GoogleSignIn.getClient(this,GoogleSignInoptions.DEFAULT_GAMES_SIGN_IN)
val intent = signInClient.signInIntent
startActivityForResult(intent,RC_SIGN_IN)
}
override fun onActivityResult(requestCode: Int,resultCode: Int,data: Intent?) {
super.onActivityResult(requestCode,resultCode,data)
if (requestCode == RC_SIGN_IN) {
val result = Auth.GoogleSignInApi.getSignInResultFromIntent(data)
if (result!!.isSuccess) {
mServerAuthCode = result.signInAccount!!.serverAuthCode
// The signed in account is stored in the result.
val signedInAccount = result.signInAccount
} else {
var message = result.status.statusMessage
if (message == null || message.isEmpty()) {
message = getString(R.string.signin_other_error)
}
AlertDialog.Builder(this).setMessage(message)
.setNeutralButton(android.R.string.ok,null).show()
}
}
}
private fun showAchievements() {
Games.getAchievementsClient(this,GoogleSignIn.getLastSignedInAccount(this)!!)
.achievementsIntent
.addOnSuccessListener { intent -> startActivityForResult(intent,RC_ACHIEVEMENT_UI) }
}
private val RC_leaderBOARD_UI = 9004
private fun showleaderboard() {
Games.getleaderboardsClient(this,GoogleSignIn.getLastSignedInAccount(this)!!)
.getleaderboardIntent(getString(R.string.leaderboard_marathon))
.addOnSuccessListener { intent -> startActivityForResult(intent,RC_leaderBOARD_UI) }
}
private fun showleaderboard2() {
Games.getleaderboardsClient(this,GoogleSignIn.getLastSignedInAccount(this)!!)
.getleaderboardIntent(getString(R.string.leaderboard_timer_mode))
.addOnSuccessListener { intent -> startActivityForResult(intent,RC_leaderBOARD_UI) }
}
private fun signOut() {
val signInClient = GoogleSignIn.getClient(this,GoogleSignInoptions.DEFAULT_GAMES_SIGN_IN)
signInClient.signOut().addOnCompleteListener(this
) {
// at this point,the user is signed out.
}
}
private fun signInSilently() {
val signInoptions = GoogleSignInoptions.DEFAULT_GAMES_SIGN_IN
val account = GoogleSignIn.getLastSignedInAccount(this)
if (GoogleSignIn.hasPermissions(account,*signInoptions.scopeArray)) {
// Already signed in.
// The signed in account is stored in the 'account' variable.
val signedInAccount = account
} else {
// Haven't been signed-in before. Try the silent sign-in first.
val signInClient = GoogleSignIn.getClient(this,signInoptions)
signInClient
.silentSignIn()
.addOnCompleteListener(
this
) { task ->
if (task.isSuccessful) {
val signedInAccount = task.result
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)