gpt4 book ai didi

android - 检测从 Google Play 用户界面退出

转载 作者:太空宇宙 更新时间:2023-11-03 10:44:31 24 4
gpt4 key购买 nike

我的游戏目前使用菜单中的登录和退出按钮来使用 Google Play 排行榜/成就。不幸的是,用户也可以从 Google Play UI 注销,但当他们通过 Google 的 UI 执行此操作时,GameHelper.isSignedIn() 仍会返回 true。当用户以这种方式退出后尝试查看排行榜或成就时,游戏会崩溃。

有谁知道检查用户是否通过 UI 注销的更新方法?我说更新是因为我在 stackoverflow 中看到一些线程不起作用。

最佳答案

我刚刚关注了 https://developers.google.com/games/services/training/signin一切正常。它正在使用

boolean mExplicitSignOut = false;
boolean mInSignInFlow = false; // set to true when you're in the middle of the
// sign in flow, to know you should not attempt
// to connect in onStart()
GoogleApiClient mGoogleApiClient; // initialized in onCreate

@Override
protected void onStart() {
super.onStart();
if (!mInSignInFlow && !mExplicitSignOut) {
// auto sign in
mGoogleApiClient.connect();
}
}

@Override
public void onClick (View view) {
if (view.getId() == R.id.sign_out_button) {
// user explicitly signed out, so turn off auto sign in
mExplicitSignOut = true;
if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
Games.signOut(mGoogleApiClient);
mGoogleApiClient.disconnect();
}
}
}

关于android - 检测从 Google Play 用户界面退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26317577/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com