The Android client also uses the provided banking-client module to interact with the server, but in this case, it's necessary to use the asynchronous method to make requests (this requirement comes from the nature of how Android works). We can also say that this is a fat client, by looking at the definition provided earlier.
Let's review the structure of this project in the following screenshot:
The Activity classes have the code to make the asynchronous requests, as follows:
SecurityApi api = BankClient.getRetrofit().create(SecurityApi.class);
Call<String> call = api.login(new Credentials(username, password));
call.enqueue(new Callback<String>()
{
@Override
public void onResponse(Call<String> call,
Response<String> response)
{
// do something with the reponse
}
@Override
public void onFailure(Call<String> call, Throwable t)
{
// handle the error properly
}
}
The enqueue method allows for hitting the endpoint asynchronously, and it registers two callbacks that will be executed, depending on whether the response fails or succeeds.
The execution flow for this client application is shown in the following screenshot: