This guide explains how to make remote calls from your app to the Spotify app with the App Remote SDK.

When you make a call via any of the APIs you receive an instance of a CallResult object. CallResult lets you receive results both asynchronously or synchronously. Lets take a look at the example of a synchronous call:

CallResult<PlayerState> playerStateCall = playerApi.getPlayerState();
Result<PlayerState> playerStateResult = playerStateCall.await(10, TimeUnit.SECONDS);
if (playerStateResult.isSuccessful()) {
    PlayerState playerState = playerStateResult.getData();
    // have some fun with playerState
} else {
    Throwable error = playerStateResult.getError();
    // try to have some fun with the error

And the preferable async way to do the same thing:

        .setResultCallback(playerState -> {
            // have fun with playerState
        .setErrorCallback(throwable -> {
            // =(

As a result of subscription you receive a Subscription object. For example:

        .setEventCallback(playerState -> {
            // the Spotify App keeps you updated on PlayerState with this event
        .setErrorCallback(throwable -> {
            // =( =( =(