2014-05-20 10 views
0

Google Play 게임 서비스에 문제가 있습니다. 앱을 전환하고 집을 선택하여 게임을 시작하고 시작하는 동안 리더 보드가 무작위로 시작됩니다. 어떻게이 행동을 바꿀 수 있습니까?Google Play 게임 서비스

if (isSignedIn()) { 
     startActivityForResult(getGamesClient().getAllLeaderboardsIntent(), 
       RC_UNUSED); 
public int gameMode; 

public static void showLeaderboard(int mode) { 
    me.gameMode = mode; 
    me.runOnUiThread(new Runnable() { 
     public void run() { 
      if (me.isSignedIn()) 
       me.onShowLeaderboard(); 
      else 
       me.SignIn(); 
     } 
    }); 
} 

public static void submitScore(final int score) { 
    me.gameMode = score/1000000; 
    me.runOnUiThread(new Runnable() { 
     public void run() { 
      me.onSubmitScore(score % 1000000); 
     } 
    }); 

} 


    public void onShowLeaderboard() { 
    if (isSignedIn()) { 
     startActivityForResult(getGamesClient().getAllLeaderboardsIntent(), 
       RC_UNUSED); 
    } else { 
     showAlert(getString(R.string.signing_in)); 
     this.SignIn(); 
    } 
} 

public void onSubmitScore(int score) { 
    if (isSignedIn()) { 
     switch (gameMode) { 
     case 1: 
      getGamesClient().submitScore(getString(R.string.leaderboard1), 
        score); 
      break; 
     case 2: 
      getGamesClient().submitScore(getString(R.string.leaderboard2), 
        score); 
      break; 
     case 3: 
      getGamesClient().submitScore(getString(R.string.leaderboard3), 
        score); 
      break; 
     } 
    } else { 
     showAlert(getString(R.string.signing_in)); 
     this.SignIn(); 
    } 
} 

boolean verifyPlaceholderIdsReplaced() { 
    final boolean CHECK_PKGNAME = true; // set to false to disable check 
             // (not recommended!) 

    // Did the developer forget to change the package name? 
    if (CHECK_PKGNAME && getPackageName().startsWith("com.google.example.")) { 
     Log.e(TAG, 
       "*** Sample setup problem: " 
         + "package name cannot be com.google.example.*. Use your own " 
         + "package name."); 
     return false; 
    } 

    return true; 
} 

public void SignIn() { 
    if (!verifyPlaceholderIdsReplaced()) { 
     showAlert("Sample not set up correctly. See README."); 
     return; 
    } 

    // start the sign-in flow 
    beginUserInitiatedSignIn(); 
} 

@Override 
public void onSignInFailed() { 
    System.out.println("SignIn Failed!"); 
} 

@Override 
public void onSignInSucceeded() { 
    System.out.println("SignIn Successed!"); 
    onShowLeaderboard(); 
} 
+0

사람이에 도움이 될 수 있습니다? – user3655025

답변

2

나는 당신의 방법에 당신이 전화를 'onSignInSucceeded'때문입니다 생각 'onShowLeaderboard를();' 그래서 응용 프로그램이 시작될 때마다 (처음 또는 다시 시작될 때) 로그인되고 로그인 프로세스가 성공하면 'onShowLeaderboard();'메서드가 시작됩니다.

0

특정 리더 보드를 들어 당신은 사용해야

startActivityForResult(Games.Leaderboards.getLeaderboardIntent(getApiClient(), 
       YOUR_LEADERBOARD_ID), REQUEST_LEADERBOARD); 

대신를 사용 :

startActivityForResult(getGamesClient().getAllLeaderboardsIntent(), 
      RC_UNUSED); 
관련 문제