我尝试在我的游戏中实现 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)) this question 中的建议.
关于android - Google Game Play Service Achievement 不弹出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39851367/