我如何检查是否从游戏服务的默认视图的用户登录的了呢? [英] How can i check if user sign's out from games services default view?

查看:164
本文介绍了我如何检查是否从游戏服务的默认视图的用户登录的了呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在游戏中集成谷歌游戏服务,包括排行榜和成就。如果用户打开排行榜和成就的活动,他已经从设置标志在右上角的可能性。

I integrated google games services in my game, including Leaderboards and achievements. If the user opens the leaderboard or achievement activity, he has the possibility to sign out from the settings in the right upper corner.

我如何检查,如果用户在实际签署? getGamesClient.isConnected()仍然是正确的,虽然用户从谷歌的观点登出。

How can I check if the user is actually signed in? getGamesClient.isConnected() is still true, although the user logged out from the google view.

如果我点击退出按钮(这是仍然存在,becaus gamesClient仍处于连接状态),我得到一个SecurityException异常:

If I'm clicking the logout button (which is still there, becaus gamesClient is still connected) I get an SecurityException:

11月8日至16日:01:21.262 14288-14288 /? E / AndroidRuntime:致命异常:主要         java.lang.SecurityException异常         在android.os.Parcel.readException(Parcel.java:1425)         在android.os.Parcel.readException(Parcel.java:1379)         在com.google.android.gms.internal.bm $ A $ AA(来源不明)         在com.google.android.gms.internal.bj.signOut(来源不明)         在com.google.android.gms.games.GamesClient.signOut(来源不明)

08-16 11:01:21.262 14288-14288/? E/AndroidRuntime: FATAL EXCEPTION: main java.lang.SecurityException at android.os.Parcel.readException(Parcel.java:1425) at android.os.Parcel.readException(Parcel.java:1379) at com.google.android.gms.internal.bm$a$a.a(Unknown Source) at com.google.android.gms.internal.bj.signOut(Unknown Source) at com.google.android.gms.games.GamesClient.signOut(Unknown Source)

目前,我检查了ActivityForResult响应code和断开GamesClient,如果它在不一致的状态,但我不喜欢这种做法。

At the moment, I am checking the ActivityForResult response code and disconnecting the GamesClient, if it's in inconsistent state, but I don't like that approach.

推荐答案

尝试处理onActivityResult:

Try handling onActivityResult:

public boolean onActivityResult(int requestCode, int resultCode, Intent data)
{
    if (requestCode == RC_YOUR_UNIQUE_ID 
            && resultCode == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED) {
        mHelper.disconnect();
        // update your logic here (show login btn, hide logout btn).            
    } else {
        mHelper.onActivityResult(requestCode, resultCode, data);
    }
    return false;
}

RC_YOUR_UNIQUE_ID是ID你用来显示排行榜和成就的活动。

RC_YOUR_UNIQUE_ID is id you've used for showing Leaderboard or Achievements activity.

这篇关于我如何检查是否从游戏服务的默认视图的用户登录的了呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆