Requests

The VoiceLayer SDK provides two ways to perform every server request:

Synchronous

This version will perform the request synchronously and return the result directly if applicable. These methods perform blocking network requests on the calling thread and should not be called from the main thread. Instead these methods are meant to be called from a background thread using an Async Task or Intent Service, for example.

VoiceLayerUser user = client.login("email", "password");

If the request fails for any reason an instance of VoiceLayerException will be thrown. If no exception is thrown it can be assumed that the request completed successfully.

Asynchronous

This version will perform the request asynchronously and report the result back to the provided callback interface. These methods perform the network requests on a background thread and can safely be called from the main thread.

client.login("email", "password", new VoiceLayerLoginCallback() {
@Override
    public void onLoginComplete(VoiceLayerUser user, String sessionToken, VoiceLayerException exception) {

    }
});

If the request fails for any reason an instance of VoiceLayerException will be passed to the callback. If the exception parameter in the callback is null it can be assumed that the request completed successfully.