有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Google Play游戏无法再次登录

问题很简单,谷歌是否有可能在没有活动的情况下提供游戏服务

我可以第一次登录,一切正常。当我让它注销并再次尝试登录时,问题就出现了(signin->;signout->;signin),它根本不起作用

代码如下:

public final class GooglePlayGameServices 
{
    private static Activity ua;//Unity Activity
    private static GameHelper gameHelper = null;
    private static GameHelperListener gameHelperListener= null;

    public static void signIn()
    {
        if (ua == null)
        {
            ua = UnityPlayer.currentActivity;
        }

        ua.runOnUiThread(new Runnable() {public void run() 
        {
            if (gameHelper == null)
            {
                conectedInPast = false;
                gameHelper = new GameHelper(ua, GameHelper.CLIENT_GAMES);
                gameHelperListener = new GameHelperListener() {

                    @Override
                    public void onSignInSucceeded() {
                        // TODO Auto-generated method stub

                    }

                    @Override
                    public void onSignInFailed() {
                        // TODO Auto-generated method stub

                    }
                };

                gameHelper.setup(gameHelperListener);
                gameHelper.enableDebugLog(true);
            }

            if (!gameHelper.isConnecting() && !gameHelper.isSignedIn())
            {
                gameHelper.beginUserInitiatedSignIn();
            }
            else
            {
                if (gameHelper.isConnecting())
                {
                    gameHelper.makeSimpleDialog("You are connecting. Please be patient").show();
                }
                else if (gameHelper.isSignedIn())
                {
                    gameHelper.makeSimpleDialog("You have already signed in").show();
                }
            }

        }});            
    }

    public static void signOut()
    {
        if (gameHelper != null)
        {
            ua.runOnUiThread(new Runnable() {public void run() 
            {
                gameHelper.signOut();
            }});
        }
    }

    public static boolean isSignedIn()
    {
        return gameHelper != null&& gameHelper.isSignedIn();
    }

    public static void showLeaderBoard(final String leaderboardID)
    {
        ua.runOnUiThread(new Runnable() {public void run() 
        {
            ua.startActivityForResult(Games.Leaderboards.getLeaderboardIntent(gameHelper.getApiClient(), leaderboardID), 5342);
        }});
    }   

}

这是下次登录时的日志:

05-25 13:14:13.092: D/GameHelper(21003): GameHelper: beginUserInitiatedSignIn: resetting attempt count.
05-25 13:14:13.093: D/GameHelper(21003): GameHelper: Starting USER-INITIATED sign-in flow.
05-25 13:14:13.093: D/GameHelper(21003): GameHelper: beginUserInitiatedSignIn: starting new sign-in flow.
05-25 13:14:13.093: D/GameHelper(21003): GameHelper: Starting connection.
05-25 13:14:13.094: E/GooglePlayServicesUtil(21003): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
05-25 13:14:13.140: D/GameHelper(21003): GameHelper: onConnectionFailed
05-25 13:14:13.140: D/GameHelper(21003): GameHelper: Connection failure:
05-25 13:14:13.140: D/GameHelper(21003): GameHelper:    - code: SIGN_IN_REQUIRED(4)
05-25 13:14:13.140: D/GameHelper(21003): GameHelper:    - resolvable: true
05-25 13:14:13.140: D/GameHelper(21003): GameHelper:    - details: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{421e1d10: 安卓.os.BinderProxy@421e1cb0}}
05-25 13:14:13.140: D/GameHelper(21003): GameHelper: onConnectionFailed: WILL resolve because user initiated sign-in.
05-25 13:14:13.140: D/GameHelper(21003): GameHelper: onConnectionFailed: resolving problem...
05-25 13:14:13.141: D/GameHelper(21003): GameHelper: resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{421e1d10: 安卓.os.BinderProxy@421e1cb0}}
05-25 13:14:13.141: D/GameHelper(21003): GameHelper: Result has resolution. Starting it.
05-25 13:14:13.141: I/ActivityManager(990): START u0 {flg=0x4000000 cmp=com.google.安卓.gms/.games.ui.signin.SignInActivity (has extras)} from pid -1
05-25 13:14:13.147: W/ContextImpl(1286): Calling a method in the system process without a qualified user: 安卓.app.ContextImpl.sendBroadcast:1244 安卓.content.ContextWrapper.sendBroadcast:365 com.motorola.motocare.util.TriggerHelper$TriggerBuilder.send:76 com.motorola.motocare.internal.frameworkevents.PauseResumeTrigger.handleFrameworkEvent:53 com.motorola.motocare.internal.frameworkevents.FwEventMonitor$FrameworkListener.processFrameworkEvent:114 
05-25 13:14:13.172: D/Volley(14199): [1] Request.finish: 32233 ms: [ ] https://安卓.clients.google.com/fdfe/bulkDetails 0xe8d195d1 NORMAL 1
05-25 13:14:13.647: W/ActivityManager(990): Activity pause timeout for ActivityRecord{4237a8c0 u0 com.clinko.dovestw/com.unity3d.player.UnityPlayerNativeActivity t24}
05-25 13:14:13.650: W/ContextImpl(1286): Calling a method in the system process without a qualified user: 安卓.app.ContextImpl.sendBroadcast:1244 安卓.content.ContextWrapper.sendBroadcast:365 com.motorola.motocare.util.TriggerHelper$TriggerBuilder.send:76 com.motorola.motocare.internal.frameworkevents.PauseResumeTrigger.handleFrameworkEvent:53 com.motorola.motocare.internal.frameworkevents.FwEventMonitor$FrameworkListener.processFrameworkEvent:114 
05-25 13:14:13.657: I/SFPerfTracer(271):      triggers: (rate: 0:0) (176027 sw vsyncs) (0 skipped) (194:116854 vsyncs) (196:299645)
05-25 13:14:13.730: D/Sensors(990): AccelerationSensor: Set Sensors state 0x2
05-25 13:14:13.730: D/Sensors(990): AccelerationSensor: set delay 0
05-25 13:14:13.739: I/Choreographer(21003): Skipped 34 frames!  The application may be doing too much work on its main thread.
05-25 13:14:13.795: I/SBar.NetworkController(1111): onDataActivity: direction=3
05-25 13:14:13.798: I/SBar.NetworkController(1111): refreshSignalCluster: mobile: mHasMobileDataFeature=true DataTypeShown=zz_moto_stat_sys_data_fully_connected_h_wide Activity=zz_moto_stat_sys_data_fully_connected_signal_inout_wide in=false out=false Accessibility="3.5G"
05-25 13:14:13.836: I/LaunchCheckinHandler(990): Displayed com.google.安卓.gms/.games.ui.signin.SignInActivity,wp,ca,189
05-25 13:14:13.836: I/ActivityManager(990): Displayed com.google.安卓.gms/.games.ui.signin.SignInActivity: +189ms
05-25 13:14:14.794: I/SBar.NetworkController(1111): onDataActivity: direction=0
05-25 13:14:14.798: I/SBar.NetworkController(1111): refreshSignalCluster: mobile: mHasMobileDataFeature=true DataTypeShown=zz_moto_stat_sys_data_fully_connected_h_wide Activity=zz_moto_stat_sys_data_fully_connected_signal_none_wide in=false out=false Accessibility="3.5G"
05-25 13:14:15.041: V/AlarmManager(990): sending alarm Alarm{42cd7300 type 2 com.安卓.providers.calendar}
05-25 13:14:15.085: E/ModemStatsUtils(1219): Exception in getLastKnownLocation - Timed out waiting for response from server
05-25 13:14:15.085: D/Checkin(1219): publish the event [tag = CALL_PERF_DEVICE_LOC event name = CALL_PERF_DEVICE_LOC]
05-25 13:14:15.797: I/SBar.NetworkController(1111): onDataActivity: direction=3
05-25 13:14:15.807: I/SBar.NetworkController(1111): refreshSignalCluster: mobile: mHasMobileDataFeature=true DataTypeShown=zz_moto_stat_sys_data_fully_connected_h_wide Activity=zz_moto_stat_sys_data_fully_connected_signal_inout_wide in=false out=false Accessibility="3.5G"
05-25 13:14:16.807: I/SBar.NetworkController(1111): onDataActivity: direction=2
05-25 13:14:16.811: I/SBar.NetworkController(1111): refreshSignalCluster: mobile: mHasMobileDataFeature=true DataTypeShown=zz_moto_stat_sys_data_fully_connected_h_wide Activity=zz_moto_stat_sys_data_fully_connected_signal_out_wide in=false out=false Accessibility="3.5G"
05-25 13:14:17.341: E/ViewRootImpl(19392): Attempting to destroy the window while drawing!
05-25 13:14:17.341: E/ViewRootImpl(19392):   window=安卓.view.ViewRootImpl@4222ad40, title=
05-25 13:14:17.389: I/SFPerfTracer(271):      triggers: (rate: 16:457) (compose: 0:24) (post: 0:57) (render: 2:290) (209:61029 frames) (210:111372)
05-25 13:14:17.390: D/SFPerfTracer(271):        layers: (7:12) (DimLayer: 0:25)* (FocusedStackFrame: 0:349)* (StatusBar: 15:8589) (NavigationBar: 0:3139) (com.安卓.systemui.ImageWallpaper: 0:1087)* (DimLayer: 14:15) (com.clinko.dovestw/com.unity3d.player.UnityPlayerNativeActivity: 186:1244) (SurfaceView: 0:1538) (com.google.安卓.gms/com.google.安卓.gms.games.ui.signin.SignInActivity: 1:8) (: 208:214) 
05-25 13:14:17.470: W/GLSUser(13596): GoogleAccountDataService.getToken()
05-25 13:14:17.534: W/GLSUser(13596): GoogleAccountDataService.getToken()
05-25 13:14:17.813: I/SBar.NetworkController(1111): onDataActivity: direction=3
05-25 13:14:17.815: I/SBar.NetworkController(1111): refreshSignalCluster: mobile: mHasMobileDataFeature=true DataTypeShown=zz_moto_stat_sys_data_fully_connected_h_wide Activity=zz_moto_stat_sys_data_fully_connected_signal_inout_wide in=false out=false Accessibility="3.5G"
05-25 13:14:18.035: D/dalvikvm(2539): GC_CONCURRENT freed 1963K, 36% free 11073K/17248K, paused 3ms+12ms, total 55ms
05-25 13:14:18.131: W/GLSUser(13596): GoogleAccountDataService.getToken()
05-25 13:14:18.358: I/qtaguid(2539): Failed write_ctrl(u 172) res=-1 errno=22
05-25 13:14:18.358: I/qtaguid(2539): Untagging socket 172 failed errno=-22
05-25 13:14:18.359: W/NetworkManagementSocketTagger(2539): untagSocket(172) failed with errno -22
05-25 13:14:18.567: D/dalvikvm(990): GC_EXPLICIT freed 868K, 17% free 21692K/26020K, paused 6ms+11ms, total 149ms
05-25 13:14:18.601: W/ContextImpl(1286): Calling a method in the system process without a qualified user: 安卓.app.ContextImpl.sendBroadcast:1244 安卓.content.ContextWrapper.sendBroadcast:365 com.motorola.motocare.util.TriggerHelper$TriggerBuilder.send:76 com.motorola.motocare.internal.frameworkevents.PauseResumeTrigger.handleFrameworkEvent:53 com.motorola.motocare.internal.frameworkevents.FwEventMonitor$FrameworkListener.processFrameworkEvent:114 
05-25 13:14:18.610: W/ContextImpl(1286): Calling a method in the system process without a qualified user: 安卓.app.ContextImpl.sendBroadcast:1244 安卓.content.ContextWrapper.sendBroadcast:365 com.motorola.motocare.util.TriggerHelper$TriggerBuilder.send:76 com.motorola.motocare.internal.frameworkevents.PauseResumeTrigger.handleFrameworkEvent:53 com.motorola.motocare.internal.frameworkevents.FwEventMonitor$FrameworkListener.processFrameworkEvent:114 
05-25 13:14:18.637: W/GLSUser(13596): GoogleAccountDataService.getToken()
05-25 13:14:18.731: D/audio_hw_primary(274): out_set_parameters: enter: usecase(0: deep-buffer-playback) kvpairs: routing=2
05-25 13:14:18.731: D/audio_hw_extn(274): audio_extn_set_anc_parameters: anc_enabled:0
05-25 13:14:18.732: D/Sensors(990): AccelerationSensor: Set Sensors state 0x3
05-25 13:14:18.732: D/Sensors(990): AccelerationSensor: set delay 20
05-25 13:14:18.732: D/Sensors(990): AccelerationSensor: set delay 1
05-25 13:14:18.734: D/Sensors(990): AccelerationSensor: set delay 20
05-25 13:14:18.752: V/msm8974_platform(274): platform_get_output_snd_device: enter: output devices(0x2)
05-25 13:14:18.752: V/msm8974_platform(274): platform_get_output_snd_device: exit: snd_device(speaker)
05-25 13:14:18.752: D/audio_hw_primary(274): select_devices: out_snd_device(2: speaker) in_snd_device(0: )
05-25 13:14:18.752: V/msm8974_platform(274): platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(14)
05-25 13:14:18.935: I/SFPerfTracer(271):      triggers: (rate: 16:458) (compose: 0:24) (post: 0:57) (render: 2:291) (15:61057 frames) (16:111461)
05-25 13:14:18.935: D/SFPerfTracer(271):        layers: (5:12) (DimLayer: 0:25)* (FocusedStackFrame: 1:351)* (StatusBar: 15:8605) (NavigationBar: 4:3143) (com.安卓.systemui.ImageWallpaper: 0:1087)* (DimLayer: 0:28)* (com.clinko.dovestw/com.unity3d.player.UnityPlayerNativeActivity: 7:1313) (SurfaceView: 9:1547) (com.google.安卓.gms/com.google.安卓.gms.games.ui.signin.SignInActivity: 16:87) (: 0:228)* 
05-25 13:14:18.978: I/qtaguid(2539): Failed write_ctrl(u 172) res=-1 errno=22
05-25 13:14:18.978: I/qtaguid(2539): Untagging socket 172 failed errno=-22
05-25 13:14:18.978: W/NetworkManagementSocketTagger(2539): untagSocket(172) failed with errno -22
05-25 13:14:20.820: I/SBar.NetworkController(1111): onDataActivity: direction=0
05-25 13:14:20.823: I/SBar.NetworkController(1111): refreshSignalCluster: mobile: mHasMobileDataFeature=true DataTypeShown=zz_moto_stat_sys_data_fully_connected_h_wide Activity=zz_moto_stat_sys_data_fully_connected_signal_none_wide in=false out=false Accessibility="3.5G"
05-25 13:14:21.395: I/MDMCTBK(270): NetlinkHandler, power_supply subsys
05-25 13:14:21.395: I/MDMCTBK(270): NetlinkHandler, usbChargerStateChanged
05-25 13:14:21.395: I/MDMCTBK(270): MdmCutbackHndler,readFromFile = /sys/class/power_supply/usb/online
05-25 13:14:21.395: I/MDMCTBK(270): MdmCutbackHndler,readFromFile = 
05-25 13:14:21.395: E/MDMCTBK(270): MdmCutbackHndler,Could not open ''
05-25 13:14:21.403: I/MDMCTBK(270): NetlinkHandler, power_supply subsys
05-25 13:14:21.403: I/MDMCTBK(270): NetlinkHandler, usbChargerStateChanged
05-25 13:14:21.403: I/MDMCTBK(270): MdmCutbackHndler,readFromFile = /sys/class/power_supply/usb/online
05-25 13:14:21.404: I/MDMCTBK(270): MdmCutbackHndler,readFromFile = 
05-25 13:14:21.404: E/MDMCTBK(270): MdmCutbackHndler,Could not open ''
05-25 13:14:22.893: I/SBar.NetworkController(1111): onDataActivity: direction=0
05-25 13:14:35.333: I/SBar.NetworkController(1111): onDataActivity: direction=0
05-25 13:14:37.640: I/SBar.NetworkController(1111): onDataActivity: direction=4
05-25 13:14:37.688: D/dalvikvm(1279): GC_CONCURRENT freed 1967K, 40% free 10397K/17248K, paused 13ms+3ms, total 52ms
05-25 13:14:38.652: I/SBar.NetworkController(1111): onDataActivity: direction=3
05-25 13:14:38.656: I/SBar.NetworkController(1111): refreshSignalCluster: mobile: mHasMobileDataFeature=true DataTypeShown=zz_moto_stat_sys_data_fully_connected_h_wide Activity=zz_moto_stat_sys_data_fully_connected_signal_inout_wide in=false out=false Accessibility="3.5G"
05-25 13:14:39.657: I/SBar.NetworkController(1111): onDataActivity: direction=0
05-25 13:14:39.662: I/SBar.NetworkController(1111): refreshSignalCluster: mobile: mHasMobileDataFeature=true DataTypeShown=zz_moto_stat_sys_data_fully_connected_h_wide Activity=zz_moto_stat_sys_data_fully_connected_signal_none_wide in=false out=false Accessibility="3.5G"
05-25 13:14:42.116: I/SBar.NetworkController(1111): onDataActivity: direction=0
05-25 13:14:46.717: I/SFPerfTracer(271):      triggers: (rate: 0:0) (176027 sw vsyncs) (0 skipped) (1990:118844 vsyncs) (1992:301637)

当我读取signin状态时,它返回到断开连接状态

知道我做错了什么吗? 谢谢你的阅读


共 (1) 个答案

  1. # 1 楼答案

    如评论中所述,您绝对必须在某个地方的活动中实现onActivityResult,并从活动中调用gameHelper.onActivityResult()。这样做允许gameHelper从登录/退出活动接收结果,以更新其内部状态。如果不这样做,gameHelper将不知道当前登录状态是什么,并且可能会错误地报告用户已经登录,而实际上他们已经注销,从而阻止他们重新登录到服务中

    This discussion通过扩展UnityPlayerActivity以及一些替代想法,给出了一些实现这一点的方法

    unity插件文档的Extending the UnityPlayerActivity Java Code部分给出了一个很好的示例,说明了如何扩展UnityPlayerActivity以及在扩展时需要对清单进行的更改