jeudi 1 janvier 2015

I'm having trouble understanding how to implement a "Result Callback". Can someone point me in the right direction?


Vote count:

0




I am following this guide on google for setting up Google Play Game Services for Android.


At the section for implementing a ResultCallback it says:



In the snippet, MatchInitiatedCallback is a class that implements the ResultCallback interface. You can attach this object to the GoogleApiClient so that your game is notified whenever a match is initiated. To see how the MatchInitiatedCallback is implemented, see Taking the first turn.




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);
}
}


I created a class called "MatchInitiatedCallback" but i don't know what to do with it. I would like to just start a new intent.



// Let the player take the first turn
showTurnUI(match);


I tried starting a new intent at the showTurnUI(), but this MatchInitiatedCallback won't let me start a new intent i guess because it doesn't inherit from Activity...(?)


I don't understand these callback things well enough to know where to begin, could anyone point me in the right direction?



asked 24 secs ago

clayton33

1,318






I'm having trouble understanding how to implement a "Result Callback". Can someone point me in the right direction?

Aucun commentaire:

Enregistrer un commentaire