2015-12-22 47 views
1

我已經成功整合了Google Play遊戲服務,並且能夠成功登錄。如何顯示谷歌玩遊戲的成就?

登錄後,我想用按鈕向用戶顯示成就。我已經做了我的代碼實現如下:

// Create the Google API Client with access to Plus and Games 
     mGoogleApiClient = new GoogleApiClient.Builder(GameCentreActivity.this) 
       .addConnectionCallbacks(this) 
       .setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL) 
       .addOnConnectionFailedListener(this) 
       .addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN) 
       .addApi(Games.API).addScope(Games.SCOPE_GAMES) 
       .build(); 

     findViewById(R.id.sign_in_button).setOnClickListener(this); 
     findViewById(R.id.sign_out_button).setOnClickListener(this); 
     findViewById(R.id.show_achievements).setOnClickListener(this); 

onclick()方法,我有這樣的:

@Override 
     public void onClick(View view) { 
      // TODO Auto-generated method stub 

      if (view.getId() == R.id.sign_in_button) { 
       //beginUserInitiatedSignIn(); 
       // start the sign-in flow 
       mSignInClicked = true; 
       mGoogleApiClient.connect(); 
      } 
      else if (view.getId() == R.id.sign_out_button) { 
       // signOut(); 
       // findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE); 
       // findViewById(R.id.sign_out_button).setVisibility(View.GONE); 
       // sign out. 
       mSignInClicked = false; 
       Games.signOut(mGoogleApiClient); 
       if (mGoogleApiClient.isConnected()) { 
        mGoogleApiClient.disconnect(); 
       } 
       showSignInBar(); 
      } 
      else if (view.getId() == R.id.show_achievements){ 
       // startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient), 1); 
       Log.d("Show achievements called","show_achievements"); 
       startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient), 
         REQUEST_ACHIEVEMENTS); 
       Log.d("Show achievements ended","show_achievements"); 
      } 

     } 

但成績並不在我的屏幕上顯示的。請幫助我找到解決方案。

+0

那麼,什麼是在屏幕上顯示的活動所取得的成績後?只是空白?你有日誌嗎?你是否在開發者控制檯中定義了一個成就? – goblin

+0

是的,我已經在開發者控制檯中定義了成就。它只是顯示一個空白屏幕 – shobhan

+0

您是否嘗試過手動檢查成果api是否會返回您期望使用api資源管理器的值? https://developers.google.com/apis-explorer/#p/games/v1/games.achievements.list – goblin

回答

1

我解決我的問題,我沒有公佈在開發者控制檯遊戲,發佈遊戲時能看到

相關問題