【发布时间】:2015-02-28 10:51:56
【问题描述】:
我正在关注 this guide on google 为 Android 设置 Google Play 游戏服务。
在实现 ResultCallback 的部分它说:
在sn-p中,MatchInitiatedCallback是一个实现ResultCallback接口的类。您可以将此对象附加到 GoogleApiClient 以便在启动比赛时通知您的游戏。要了解 MatchInitiatedCallback 是如何实现的,请参阅先行一步。
public class MatchInitiatedCallback implements
ResultCallback<TurnBasedMultiplayer.InitiateMatchResult> {
@Override
public void onResult(TurnBasedMultiplayer.InitiateMatchResult result) {
// Check if the status code is not success.
Status status = result.getStatus();
if (status.isSuccess()) {
showError(status.getStatusCode());
return;
}
TurnBasedMatch match = result.getMatch();
// If this player is not the first player in this match, continue.
if (match.getData() != null) {
showTurnUI(match);
return;
}
// Otherwise, this is the first player. Initialize the game state.
initGame(match);
// Let the player take the first turn
showTurnUI(match);
}
}
我创建了一个名为“MatchInitiatedCallback”的类,但我不知道如何处理它。我想开始一个新的意图。
// Let the player take the first turn
showTurnUI(match);
我尝试在 showTurnUI() 处启动一个新意图,但我猜这个 MatchInitiatedCallback 不会让我启动一个新意图,因为它没有继承自 Activity...(?)
我不太了解这些回调的东西,不知道从哪里开始,有人能指出我正确的方向吗?
【问题讨论】:
-
我推荐starting here。
标签: android google-play google-play-services google-play-games