简体   繁体   中英

Google Game Play Service Achievement does not pop up

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM