Android API IsConnected returning TRUE after Signing Out

試著忘記壹切 提交于 2019-12-03 13:22:00

In order to keep signed-in state synced up you MUST implement onActivityResult properly.

This should look something as follows:

NOTE: this is java code, I am not sure how this will look exactly using Xamarin, but hopefully you should be able to figure it out :)

@Override
protected void onActivityResult(int requestCode, int responseCode, Intent data) {

    // check for "inconsistent state"
    if ( responseCode == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED && requestCode == <your_request_code_here> )  {  

       // force a disconnect to sync up state, ensuring that mClient reports "not connected"
       mGoogleApiClient.disconnect();
    }
}

NOTE: just make sure to replace in the code with the request code you used. You may need to check for multiple request codes too.

If you are using gameHelper classes from BaseGameUtils library(it is easier to use), you may modify the above code to this:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    gameHelper.onActivityResult(requestCode, resultCode, data);

    if (resultCode == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED){
        // force a disconnect to sync up state, ensuring that mClient reports "not connected"
        gameHelper.getApiClient().disconnect();
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!