How to Setup the Sync Delegate

Step 1: 

Start by registering your game’s activity with Skillz by calling SkillzSync.registerSyncDelegate and passing in this for both parameters. Passing in this should cause an error for the first parameter; this error will be resolved in Step 2. The registerSyncDelegate signature is intended to be extensible for all projects (e.g.: interface implementation also works with Fragments API, by passing getActivity() as the second parameter):

Note: Skillz will handle clean-up of the registered SyncDelegate after a score or abort has been reported.

Example:

public class GameActivity extends SkillzActivity {
    ...
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        SkillzSync.registerSyncDelegate(this, this);

       ... 
    }
}

Step 2: 

The SkillzSync.java API calls invoke the methods on the registered SyncDelegate to provide you with callbacks to handle game updates. The SyncDelegate methods are declared in an interface as a part of the SkillzSync class. Implement the SkillzSync.SyncDelegate interface in your app's game Activity:

Example:

public class GameActivity extends SkillzActivity implements SkillzSync.SyncDelegate {
    ...
}

Step 3: 

Adding the above implementation should have resulted in an error. Hover over the error (ie. implements SkillzSync.SyncDelegate) and click Option Enter to open the Intention Actions menu. Select Implement Methods from the dropdown and see the generated @Override method stubs at the bottom of the class. We will start by implementing the methods required to get up and running with Synchronous play:

Example:

@Override
public void onOpponentHasLostConnection(long playerId) {
}

@Override
public void onOpponentHasReconnected(long playerId) {
}

@Override
public void onOpponentHasLeftMatch(long playerId) {
}

@Override
public void onCurrentPlayerHasLostConnection() {
}

@Override
public void onCurrentPlayerHasReconnected() {
}

@Override
public void onCurrentPlayerHasLeftMatch() {
}

@Override
public void onDidReceiveData(@NonNull byte[] data) {
}

@Override
public void onMatchCompleted() {
}

Next Step: Handle Match Start