Google 游戏服务成就不弹出
Google Game Play Service Achievement does not pop up
我尝试在我的游戏中实现 Game Play Service Achievement,但是当解锁成就时,它不会弹出(显示成就已解锁)但是当我打开所有成就列表时它显示已解锁。所以我的问题是,解锁后如何弹出成就?
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));
您需要调用getAchievementsIntent()
创建默认成就UI,然后调用startActivityForResult
startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient),REQUEST_ACHIEVEMENTS);
有关 displaying achievements 的更多信息可以在文档中找到。
如果您需要特定于正在解锁的成就的通知,您可以尝试使用 [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.
我尝试在我的游戏中实现 Game Play Service Achievement,但是当解锁成就时,它不会弹出(显示成就已解锁)但是当我打开所有成就列表时它显示已解锁。所以我的问题是,解锁后如何弹出成就?
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));
您需要调用getAchievementsIntent()
创建默认成就UI,然后调用startActivityForResult
startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient),REQUEST_ACHIEVEMENTS);
有关 displaying achievements 的更多信息可以在文档中找到。
如果您需要特定于正在解锁的成就的通知,您可以尝试使用 [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.