I try to implement Game Play Service Achievement in my game, but when achievement is unlocked, it does not pops up (show that achievement is unlocked) but when I open list of all achievements it shows that is unlocked. So my problem is, how to pops up achievement when it's unlocked ?
MainActivity.class
public static GoogleApiClient mGoogleApiClient;
private void callGooglePlay(){
mGoogleApiClient = new GoogleApiClient.Builder(getApplicationContext())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
.build();
}
PlayActivity.class
Games.Achievements.unlock(MainMenu.mGoogleApiClient, getResources().getString(R.string.e));
You need to call the getAchievementsIntent()
to create the default achievements UI, and then call the startActivityForResult
startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient),REQUEST_ACHIEVEMENTS);
More information about displaying achievements can be found on the documentation.
If you need a notification that's specific to the achievement being unlocked, you can try to use [setViewForPopups
](https://developers.google.com/android/reference/com/google/android/gms/games/Games.html#setViewForPopups(com.google.android.gms.common.api.GoogleApiClient, android.view.View)) as suggested in this question.