如果用户从Achievements(或其他)对话框中注销,则isSignIn()仍然返回true。一些代码示例:
我有这个按钮:
achievementsBtn = new TextButton("achievements", menuBtnStyle);
achievementsBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (MyGdxGame.actionResolver.getSignedInGPGS())
MyGdxGame.actionResolver.getAchievementsGPGS();
else MyGdxGame.actionResolver.loginGPGS();
}
});
,其中
@Override
public void getAchievementsGPGS() {
startActivityForResult(
Games.Achievements.getAchievementsIntent(gameHelper
.getApiClient()), 101);
}
@Override
public boolean getSignedInGPGS() {
return gameHelper.isSignedIn();
}
用户点击此处退出并返回游戏时间后,他点击了成就按钮游戏崩溃。
有这个例外:
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: FATAL EXCEPTION: GLThread 279
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: Process: ru.zuko.game.android, PID: 29940
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: java.lang.SecurityException: Not signed in when calling API
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: at android.os.Parcel.readException(Parcel.java:1546)
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: at android.os.Parcel.readException(Parcel.java:1499)
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: at com.google.android.gms.games.internal.IGamesService$Stub$Proxy.lm(Unknown Source)
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: at com.google.android.gms.games.internal.GamesClientImpl.lm(Unknown Source)
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: at com.google.android.gms.games.internal.api.AchievementsImpl.getAchievementsIntent(Unknown Source)
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: at ru.zuko.game.android.AndroidLauncher.getAchievementsGPGS(AndroidLauncher.java:292)
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: at ru.zuko.screens.StartScreen$4.clicked(StartScreen.java:116)
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: at com.badlogic.gdx.scenes.scene2d.utils.ClickListener.touchUp(ClickListener.java:89)
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: at com.badlogic.gdx.scenes.scene2d.InputListener.handle(InputListener.java:58)
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: at com.badlogic.gdx.scenes.scene2d.Stage.touchUp(Stage.java:348)
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: at com.badlogic.gdx.backends.android.AndroidInput.processEvents(AndroidInput.java:361)
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:420)
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)
10-15 19:23:56.988 29940-29989/ru.zuko.game.android E/AndroidRuntime: at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
如何让我的游戏正常运作?