Logging out in google play games UI does not refresh information in java bridge

  • TinyMine
    Likes 0

    Problem Description

    Hey ladies and gents,

    this is a bug I found when using the google play games and sonars integration.

    So step by step:

    - when we call something like “showAchievements()” then we see the given UI by google play games

    - by then we can choose to the top right corner (version 25) and by hitting the native options button from the phone a options menu from google play games.

    - in this we can log out our account from google play games for our app.

    - when we click on this and log us out then google play games ui will be closed and you will find yourself back in your paused app which is now resuming fine.

    → so far so good.

    - BUT now a problem occurs. Sonars java class and helpers for google play games did not realize that and still handle you as logged in. The game will even crash!

    - Starting the game new – everything is fine. You will be logged in and so on. But when logging out in google play games ui and playing on without restarting the game and obviously fill the helper instances with the right information theg ame will hit crashes when you use google play games api stuff.

     

    Solution?

    My guess: making the google play games helper have a onResume() method which will be called when entering the app again (and leaving google play games for example). Then check if app is still connected or user is still logged in and refill the variables like mConnected with the probably new information.

     

    Keep up the great work; Kind regards

    Tiny!


  • TinyMine
    Likes 0

    Solution into this we tried and succesfully integrated:

    GooglePlayGames.java (<122+>)

        public void onActivityResult(int request, int response, Intent data)
        { 
            if (response == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED) {
                mHelper.disconnect();           
            } else {
                mHelper.onActivityResult(request, response, data);
            }
        }

    What have we done? We were asking for the result code the google app (ui) will give us as soon as it is finished.

    Based on this result we are just asking for the “GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED” which needs to be imported first by:

    import com.google.android.gms.games.GamesActivityResultCodes;

    Is the result code equal we disconnect the helper respectively the mGoogleApiClient which is stored in the helper. This way the framework itself does realize, that the logout was done.

    No Bugs occured since integration of this fix.

Login to reply