Some users in this site asked my question like this unlocked-popup-not-showing and Unlocked Achievement Popup not shown but doesn't work for me I don't know what is wrong in my code?
Firstly to clear my question for all users. My Question is How can I show a pop-up notification for unlocked Achievement
? like this image:
Secondly my android class MainActivity
implements the following:
public class MainActivity extends AndroidApplication implements IGoogleServices, GameHelperListener {
private GameHelper _gameHelper;
.......
which IGoogleServices
interface is:
public interface IGoogleServices {
.....
public boolean isSignedIn();
public void unlockAchievement(String achievementId);
public void showAchievements();
}
Thirdly the code in onCreate
method:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
// Create the GameHelper.
_gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
_gameHelper.enableDebugLog(true);
_gameHelper.setup(this);
initialize(new MyGdxGame(this, this), config);
}
Fourthly the implementaion methods:
@Override
public void unlockAchievement(String achievementId) {
if (isSignedIn()) {
Games.Achievements.unlock(_gameHelper.getApiClient(), achievementId);
}
}
Fifthly I threw the IGoogleServices
interface into MyGdxGame
game:
public MyGdxGame(IGoogleServices googleServices) {
this.googleServices = googleServices;
}
Finally I created Image
as button to unlock the first achievement:
final Image iAch1 = new Image(ach1);
iAch1.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
return true;
}
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
googleServices.unlockAchievement("CgkIzZ.......");
}
});
stage.addActor(iAch1);
So far everything is okay and the Achievements
unlocked BUT without pop-up
notifications as shown in previous image. How can I achieve that?