I create an achievement called Sign in Play Games and try to unlock it onSingIn ().
@Override
public boolean unlockAchievements() {
boolean r = true;
if (gameHelper.isSignedIn()){
try{
Games.Achievements.unlock(gameHelper.getApiClient(), getString(R.string.achievement_sign_in_play_games));
}
catch(Exception ex){
r = false;
}
finally{
}
}
else{
r = false;
}
return r;
}
In case of resizing the screen on the screen where my login button is located, I will implement this code:
@Override
public void resize(int width, int height) {
if(game.gameHelper.isSignedIn()){
if (!game.gameHelper.unlockAchievements()){
game.gameHelper.forceSignOut();
}
}
}
ForceSignOut () was implemented in the GameHelper class
public void forceSignOut() {
if (mGoogleApiClient != null){
mGoogleApiClient.disconnect();
}
}
And finally, in BaseGameActivity:
protected void forceSignOut(){
mHelper.forceSignOut();
}
Remember to implement your GameServiceInterface:
public void forceSignOut();
source
share