2016-10-04 114 views
1

我嘗試在我的遊戲中實現遊戲服務成就,但是當成就解鎖後,它不會彈出(顯示成就已解鎖),但是當我打開所有成就列表時它顯示已解鎖。所以我的問題是,如何在成功解鎖時彈出成就?谷歌遊戲服務成就不會彈出

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)); 
+0

你在UIThread上運行它嗎? – shalafi

+0

另外,彈出窗口僅在您第一次解鎖它時出現,它是基於雲的,您需要在Play遊戲機服務器端重置它。 – shalafi

+0

是的,它在UIThread上運行。 即使第一次解鎖,它也不會出現。 – stellyrepsolka

回答

0

你需要調用getAchievementsIntent()創建默認的成就UI,然後調用startActivityForResult

startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient),REQUEST_ACHIEVEMENTS); 

有關displaying achievements的更多信息,請參見文檔。

如果你需要一個通知的具體的成就被解鎖,您可以嘗試使用[setViewForPopupshttps://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建議。