• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GamesClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: onRoomConnected

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
@Override
public void onRoomConnected(int statusCode, Room room) {
    Log.d(TAG, "onRoomConnected(" + statusCode + ", " + room + ")");
    if (statusCode != GamesClient.STATUS_OK) {
        Log.e(TAG, "*** Error: onRoomConnected, status " + statusCode);
        showScreen(Screen.ERROR);
        return;
    }
    updateRoom(room);
}
 
开发者ID:kingori,项目名称:ihatecolor_and,代码行数:11,代码来源:MainActivity.java


示例17: handleInvitationInboxResult

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
private void handleInvitationInboxResult(int response, Intent data) {
    if (response != Activity.RESULT_OK) {
        Log.w(TAG, "*** invitation inbox UI cancelled, " + response);
        showScreen(Screen.MAIN);
        return;
    }

    Log.d(TAG, "Invitation inbox UI succeeded.");
    Invitation inv = data.getExtras().getParcelable(GamesClient.EXTRA_INVITATION);

    // accept invitation
    acceptInviteToRoom(inv.getInvitationId());
}
 
开发者ID:kingori,项目名称:ihatecolor_and,代码行数:14,代码来源:MainActivity.java


示例18: onConnected

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
protected void onConnected(GoogleSignInAccount googleSignInAccount) {
    Log.d("SIGNIN", "onConnected(): connected to Google APIs");
    if (mSignedInAccount != googleSignInAccount) {

        mSignedInAccount = googleSignInAccount;

        // update the clients
        mRealTimeMultiplayerClient = Games.getRealTimeMultiplayerClient(this, googleSignInAccount);
        SpaceRace.messageManager.setRealTimeMultiplayerClient(mRealTimeMultiplayerClient);
        mInvitationsClient = Games.getInvitationsClient(this, googleSignInAccount);

        // get the playerId from the PlayersClient
        PlayersClient playersClient = Games.getPlayersClient(this, googleSignInAccount);
        playersClient.getCurrentPlayer().addOnSuccessListener(
                new OnSuccessListener<Player>() {
                    @Override
                    public void onSuccess(Player player) {
                        mPlayerId = player.getPlayerId();
                        SpaceRace.messageManager.setParticipantId(mPlayerId);
                    }
                }
        );

        requestPermissionsNeeded();
    }

    // register listener so we are notified if we receive an invitation to play
    // while we are in the game
    mInvitationsClient.registerInvitationCallback(mInvitationCallback);

    // get the invitation from the connection hint
    // Retrieve the TurnBasedMatch from the connectionHint
    GamesClient gamesClient = Games.getGamesClient(this, googleSignInAccount);
    gamesClient.getActivationHint()
            .addOnSuccessListener(new OnSuccessListener<Bundle>() {
                @Override
                public void onSuccess(Bundle hint) {
                    if (hint != null) {
                        Invitation invitation =
                                hint.getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);

                        if (invitation != null && invitation.getInvitationId() != null) {
                            // retrieve and cache the invitation ID
                            Log.d("ROOM", "onConnected: connection hint has a room invite!");
                            acceptInviteToRoom(invitation.getInvitationId());
                        }
                    }
                }
            })
            .addOnFailureListener(createFailureListener("There was a problem getting the activation hint!"));
}
 
开发者ID:Augugrumi,项目名称:SpaceRace,代码行数:52,代码来源:AbsRoomActivity.java


示例19: getGamesClient

import com.google.android.gms.games.GamesClient; //导入依赖的package包/类
protected GamesClient getGamesClient() {
    return mHelper.getGamesClient();
}
 
开发者ID:kebernet,项目名称:shortyz,代码行数:4,代码来源:BaseGameActivity.java


示例20: 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) {

    // Don't retain references to old matches.
    mTurnBasedMatch = null;

    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.");

        TurnBasedMatch match = connectionHint
                .getParcelable(GamesClient.EXTRA_TURN_BASED_MATCH);

        if (match != null) {
            mTurnBasedMatch = match;
        }

    }

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ChannelBufferOutputStream类代码示例发布时间:2022-05-21
下一篇:
Java SearchQuery类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap