当前位置: 首页>>代码示例>>Java>>正文


Java GamesClient类代码示例

本文整理汇总了Java中com.google.android.gms.games.GamesClient的典型用法代码示例。如果您正苦于以下问题:Java GamesClient类的具体用法?Java GamesClient怎么用?Java GamesClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GamesClient类属于com.google.android.gms.games包,在下文中一共展示了GamesClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  showButtons();

  Intent intent = getIntent();
  // Check if the activity was launched by invitation to a match.
  if (intent != null && intent.hasExtra(GamesClient.EXTRA_TURN_BASED_MATCH)) {
    Log.i(TAG, "Match found, showing GameActivity");
    TurnBasedMatchImpl match = intent.getParcelableExtra(GamesClient.EXTRA_TURN_BASED_MATCH);
    int status2 = match.getStatus();
    Log.i(TAG, "Match found, showing GameActivity" + status2 + " vs " + Match.MATCH_STATUS_ACTIVE);
    if (status2 == Match.MATCH_STATUS_ACTIVE) {
      Log.i(TAG, "Match found, showing GameActivity");
      mMatch = match;
    }
  }
}
 
开发者ID:dlazerka,项目名称:go,代码行数:20,代码来源:MainActivity.java

示例2: onAchievementsLoaded

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
@Override
public void onAchievementsLoaded(int statusCode, AchievementBuffer achBuffer) {
	if (statusCode == GamesClient.STATUS_OK) {
		Iterator<Achievement> iterator = achBuffer.iterator();
		while(iterator.hasNext()){
			Achievement achievement = iterator.next();
			if(achievement.getType() == Achievement.TYPE_INCREMENTAL && achievement.getAchievementId().equals(achievementId))
			{
			    this.incrementAchievementWhenDataIsLoaded(achievement);
			}
		}
		
	}
	else{
		//Achievements loading has failed
	}
	achBuffer.close();
}
 
开发者ID:freshplanet,项目名称:ANE-Google-Play-Game-Services,代码行数:19,代码来源:AchievementsLoadListener.java

示例3: onConnected

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
/** Called when we successfully obtain a connection to a client. */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected! client=" + mClientCurrentlyConnecting);

    // Mark the current client as connected
    mConnectedClients |= mClientCurrentlyConnecting;
    debugLog("Connected clients updated to: " + mConnectedClients);

    // If this was the games client and it came with an invite, store it for
    // later retrieval.
    if (mClientCurrentlyConnecting == CLIENT_GAMES && connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint.getParcelable(GamesClient.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // accept invitation
            debugLog("onConnected: connection hint has a room invite!");
            mInvitationId = inv.getInvitationId();
            debugLog("Invitation ID: " + mInvitationId);
        }
    }

    // connect the next client in line, if any.
    connectNextClient();
}
 
开发者ID:dbaelz,项目名称:Secludedness,代码行数:26,代码来源:GameHelper.java

示例4: onConnected

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
/** Called when we successfully obtain a connection to a client. */
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected! client=" + mClientCurrentlyConnecting);

    // Mark the current client as connected
    mConnectedClients |= mClientCurrentlyConnecting;
    debugLog("Connected clients updated to: " + mConnectedClients);

    // If this was the games client and it came with an invite, store it for
    // later retrieval.
    if (mClientCurrentlyConnecting == CLIENT_GAMES && connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint.getParcelable(GamesClient.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // accept invitation
            debugLog("onConnected: connection hint has a room invite!");
            mInvitationId = inv.getInvitationId();
            debugLog("Invitation ID: " + mInvitationId);
        }
    }

    // connect the next client in line, if any.
    connectNextClient();
}
 
开发者ID:d3alek,项目名称:TheHunt---Interactive-graphical-platform-for-AI-Experiments,代码行数:25,代码来源:GameHelper.java

示例5: getGamesClient

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
/**
 * Returns the GamesClient object. In order to call this method, you must have
 * called @link{setup} with a set of clients that includes CLIENT_GAMES.
 */
public GamesClient getGamesClient() {
    if (mGamesClient == null) {
        throw new IllegalStateException("No GamesClient. Did you request it at setup?");
    }
    return mGamesClient;
}
 
开发者ID:kebernet,项目名称:shortyz,代码行数:11,代码来源:GameHelper.java

示例6: onConnected

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
/** Called when we successfully obtain a connection to a client. */
    public void onConnected(Bundle connectionHint) {

        debugLog("onConnected: connected! client=" + mClientCurrentlyConnecting);

        // Mark the current client as connected
        mConnectedClients |= mClientCurrentlyConnecting;
        debugLog("Connected clients updated to: " + mConnectedClients);

        // If this was the games client and it came with an invite, store it for
        // later retrieval.
        if (mClientCurrentlyConnecting == CLIENT_GAMES
                && connectionHint != null) {
            debugLog("onConnected: connection hint provided. Checking for invite.");
            Invitation inv = connectionHint
                    .getParcelable(GamesClient.EXTRA_INVITATION);
            if (inv != null && inv.getInvitationId() != null) {
                // accept invitation
                debugLog("onConnected: connection hint has a room invite!");
                mInvitationId = inv.getInvitationId();
                debugLog("Invitation ID: " + mInvitationId);
            }

            debugLog("onConnected: connection hint provided. Checking for TBMP game.");

//            mTurnBasedMatch = connectionHint
//                    .getParcelable(GamesClient.EXTRA_TURN_BASED_MATCH);

        }

        // connect the next client in line, if any.
        connectNextClient();
    }
 
开发者ID:kebernet,项目名称:shortyz,代码行数:34,代码来源:GameHelper.java

示例7: submitAchievement

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
@Override
public void submitAchievement(String id) {
	if (isConnected()) {
		GamesClient client = aHelper.getGamesClient();
		client.unlockAchievement(id);
	}
}
 
开发者ID:bitbrain,项目名称:plox,代码行数:8,代码来源:MainActivity.java

示例8: start

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
public static void start(Context ctx)
{
  gamesClient = new GamesClient.Builder(ctx,
      new GooglePlayCallback("GAMES_CLIENT"),
      new GooglePlayCallback("GAMES_CLIENT"))
    .setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL)
    .setScopes(Scopes.GAMES)
    .create();

  appStateClient = new AppStateClient.Builder(ctx,
      new GooglePlayCallback("APP_STATE_CLIENT"),
      new GooglePlayCallback("APP_STATE_CLIENT"))
    .setScopes(Scopes.APP_STATE)
    .create();
}
 
开发者ID:sergey-miryanov,项目名称:ExtensionsPack,代码行数:16,代码来源:GooglePlay.java

示例9: onActivityResult

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
  super.onActivityResult(requestCode, resultCode, intent);
  switch (requestCode) {
    case REQUEST_SELECT_PLAYERS:
      if (resultCode == Activity.RESULT_OK) {
        ArrayList<String> players = intent.getStringArrayListExtra(GamesClient.EXTRA_PLAYERS);
        mOpponentPlayerId = players.get(0);

        getGamesClient().createTurnBasedMatch(this, Match.INVITE_TYPE_INVITE_ALL_NOW,
            Match.MATCH_VARIANT_ANY, mOpponentPlayerId);
      }
      break;
    case REQUEST_CODE_CREATE_MATCH:
      if (resultCode == Activity.RESULT_OK) {
        mMatch = intent.getParcelableExtra(GamesClient.EXTRA_TURN_BASED_MATCH);
        startMatch();
      }
      break;
    case REQUEST_GAME:
      if (resultCode == Activity.RESULT_OK) {
        Bundle extras = intent.getExtras();
        String score = "10";
        TurnBasedMatchImpl match = extras.getParcelable(GamesClient.EXTRA_TURN_BASED_MATCH);
        ArrayList<PlayerResult> results = new ArrayList<PlayerResult>(2);
        results.add(new PlayerResult(getGamesClient().getCurrentPlayerId(), 1,
            PlayerResult.PLACING_UNINITIALIZED));
        results.add(new PlayerResult(mOpponentPlayerId, 0, PlayerResult.PLACING_UNINITIALIZED));
        getGamesClient().finishTurnBasedMatch(this, match.getMatchId(), new byte[] {}, results);
        Toast.makeText(this, "Your score is " + score, Toast.LENGTH_LONG).show();
        // mGamesClient.finishRealTimeMatch(mMatch, arg1, arg2)
      }
  }
}
 
开发者ID:dlazerka,项目名称:go,代码行数:35,代码来源:MainActivity.java

示例10: onCreate

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  mGamesClient = new GamesClient(
      this,
      getString(R.string.app_id),
      new GamesApiListener(),
      this);
}
 
开发者ID:dlazerka,项目名称:go,代码行数:11,代码来源:GamesApiActivity.java

示例11: getConnectedGamesClient

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
@Override
public GamesClient getConnectedGamesClient() throws NotYetConnectedException {
  if (mGamesClient.isConnected()) {
    return mGamesClient;
  } else {
    throw new NotYetConnectedException();
  }
}
 
开发者ID:dlazerka,项目名称:go,代码行数:9,代码来源:GamesApiActivity.java

示例12: getGamesClient

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
/**
* Returns the GamesClient object. In order to call this method, you must have
* called @link{setup} with a set of clients that includes CLIENT_GAMES.
*/
public GamesClient getGamesClient() {
    if (mGamesClient == null) {
        throw new IllegalStateException("No GamesClient. Did you request it at setup?");
    }
    return mGamesClient;
}
 
开发者ID:ldarren,项目名称:pico-phonegap-base,代码行数:11,代码来源:GmsHelper.java

示例13: onAchievementUpdated

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
@Override
public void onAchievementUpdated(int statusCode, String achievementId){
    JSONObject json = new JSONObject();
    try{
        json.put("type", GAME_ACHIEVEMENT_UPDATED);
        json.put("statusCode", statusCode);
        switch (statusCode) {
            case GamesClient.STATUS_OK:
                // if data was successfully loaded and is up-to-date 
                json.put("achievementId", achievementId);
                break;        
            case GamesClient.STATUS_NETWORK_ERROR_NO_DATA:
                // A network error occurred while attempting to retrieve fresh data, and no data was available locally.
                break;
            case GamesClient.STATUS_INTERNAL_ERROR:
                // if an unexpected error occurred in the service 
                break;
            case GamesClient.STATUS_NETWORK_ERROR_STALE_DATA:
                // if the device was unable to communicate with the network. In this case, the operation is not retried automatically.
                break;
            case GamesClient.STATUS_CLIENT_RECONNECT_REQUIRED:
                // need to reconnect GamesClient
                mHelper.reconnectClients(clientTypes);
                break;
            case GamesClient.STATUS_LICENSE_CHECK_FAILED:
                // The game is not licensed to the user. Further calls will return the same code.
                break;
            default:
                // error
                break;
        }
    }catch(JSONException ex){
        Log.e(TAG, "GAME_ACHIEVEMENT_UPDATED ["+statusCode+"] exception: "+ex.getMessage());
        return;
    }

    PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, json);
    pluginResult.setKeepCallback(true);
    connectionCB.sendPluginResult(pluginResult);
}
 
开发者ID:ldarren,项目名称:pico-phonegap-base,代码行数:41,代码来源:PlayServices.java

示例14: onRoomCreated

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
@Override
public void onRoomCreated(int statusCode, Room room) {
    Log.d(TAG, "onRoomCreated(" + statusCode + ", " + room + ")");
    if (statusCode != GamesClient.STATUS_OK) {
        Log.e(TAG, "*** Error: onRoomCreated, status " + statusCode);
        showScreen(Screen.ERROR);
        return;
    }

    // show the waiting room UI
    showWaitingRoom(room);
}
 
开发者ID:kingori,项目名称:ihatecolor_and,代码行数:13,代码来源:MainActivity.java

示例15: onJoinedRoom

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
@Override
public void onJoinedRoom(int statusCode, Room room) {
    Log.d(TAG, "onJoinedRoom(" + statusCode + ", " + room + ")");
    if (statusCode != GamesClient.STATUS_OK) {
        Log.e(TAG, "*** Error: onRoomConnected, status " + statusCode);
        showScreen(Screen.ERROR);
        return;
    }

    // show the waiting room UI
    showWaitingRoom(room);
}
 
开发者ID:kingori,项目名称:ihatecolor_and,代码行数:13,代码来源:MainActivity.java


注:本文中的com.google.android.gms.games.GamesClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。