@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES); gameHelper.enableDebugLog(true); AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); game = new Game(this); initialize(game, config); gameHelper.setup(this); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1001) { int responseCode = data.getIntExtra("RESPONSE_CODE", 0); String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA"); String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE"); if (resultCode == RESULT_OK) { try { JSONObject jo = new JSONObject(purchaseData); String sku = jo.getString("productId"); String name = null; if (sku.equals("ryan")) name = "Ryan"; else if (sku.equals("ash")) name = "Ash"; else if (sku.equals("rob")) name = "Rob"; else if (sku.equals("battle_cat")) name = "BattleCat"; else if (sku.equals("xorp")) name = "Xorp"; else if (sku.equals("rootsworth")) name = "Rootsworth"; else if (sku.equals("snap")) name = "Snap"; else if (sku.equals("metatron")) name = "Metatron"; else if (sku.equals("abaddon")) name = "Abaddon"; pref.putBoolean(name, true); pref.flush(); } catch (JSONException e) { // alert("Failed to parse purchase data."); e.printStackTrace(); } } } super.onActivityResult(requestCode, resultCode, data); _gameHelper.onActivityResult(requestCode, resultCode, data); }
@Override public void showScores() { if (isSignedIn() == true) startActivityForResult( Games.Leaderboards.getLeaderboardIntent( _gameHelper.getApiClient(), getString(R.string.leaderboard_id)), REQUEST_CODE_UNUSED); else { // Maybe sign in here then redirect to showing scores? } }
@Override public void submitScore(long score) { if (isSignedIn() == true) { Games.Leaderboards.submitScore( _gameHelper.getApiClient(), getString(R.string.leaderboard_id), score); // // startActivityForResult(Games.Leaderboards.getLeaderboardIntent(_gameHelper.getApiClient(), // getString(R.string.leaderboard_id)), REQUEST_CODE_UNUSED); } else { // Maybe sign in here then redirect to submitting score? } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create the GameHelper _gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES); _gameHelper.enableDebugLog(false); GameHelperListener gameHelperListener = new GameHelper.GameHelperListener() { @Override public void onSignInSucceeded() { // TODO Auto-generated method stub } @Override public void onSignInFailed() { // TODO Auto-generated method stub } }; _gameHelper.setup(gameHelperListener); // signIn(); Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); // queryPurchases(); AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); config.useImmersiveMode = true; initialize(new Runners(this), config); }
protected PlusClient getPlusClient() { return mHelper.getPlusClient(); }
protected GamesClient getGamesClient() { return mHelper.getGamesClient(); }
@Override protected void onStop() { super.onStop(); mHelper.onStop(); }
@Override protected void onCreate(Bundle b) { super.onCreate(b); mHelper = new GameHelper(this); mHelper.setup(this, mRequestedClients, mAdditionalScopes); }
protected ConnectionResult getSignInError() { return mHelper.getSignInError(); }
protected String[] getScopesArray() { return mHelper.getScopesArray(); }
@Override public void getLeaderboardGPGS() { startActivityForResult( Games.Leaderboards.getAllLeaderboardsIntent(gameHelper.getApiClient()), LEADERBOARD_REQUEST); }
@Override public void unlockAchievementGPGS(String achievementId) { Games.Achievements.unlock(gameHelper.getApiClient(), achievementId); }
@Override public void submitScoreGPGS(int score, String leaderboardId) { Games.Leaderboards.submitScore(gameHelper.getApiClient(), leaderboardId, score); }
@Override public boolean getSingedInGPGS() { return gameHelper.isSignedIn(); }
protected void reconnectClients(int whichClients) { mHelper.reconnectClients(whichClients); }
protected String getScopes() { return mHelper.getScopes(); }
@Override public void getAchievementsGPGS() { startActivityForResult( Games.Achievements.getAchievementsIntent(gameHelper.getApiClient()), ACHIEVEMENTS_REQUEST); }
protected boolean hasSignInError() { return mHelper.hasSignInError(); }
protected void beginUserInitiatedSignIn() { mHelper.beginUserInitiatedSignIn(); }
protected void setSignInMessages(String signingInMessage, String signingOutMessage) { mHelper.setSigningInMessage(signingInMessage); mHelper.setSigningOutMessage(signingOutMessage); }
protected void signOut() { mHelper.signOut(); }
@Override protected void onStart() { super.onStart(); mHelper.onStart(this); }
protected void showAlert(String title, String message) { mHelper.showAlert(title, message); }
@Override protected void onActivityResult(int request, int response, Intent data) { super.onActivityResult(request, response, data); mHelper.onActivityResult(request, response, data); }
protected void showAlert(String message) { mHelper.showAlert(message); }
protected AppStateClient getAppStateClient() { return mHelper.getAppStateClient(); }
protected void enableDebugLog(boolean enabled, String tag) { mHelper.enableDebugLog(enabled, tag); }
protected boolean isSignedIn() { return mHelper.isSignedIn(); }
protected String getInvitationId() { return mHelper.getInvitationId(); }