I am an iOS developer starting to learn Android. In Swift, creating a completion handler is very simple, but I still can't find a way to do this in Java.
Sorry if this question is too noob for StackOverflow people.
Problem
I am creating a class to handle my entire Http request, which is executed using Retrofit.
I make this function my RequestHelper.java
public static void checkEmailAvailability(String email) { MyWebServiceAPI serviceAPI = retrofit.create(MyWebServiceAPI.class); Call<APIResults> call = serviceAPI.checkEmailAvailability(getAuthenticationHeader(), RequestBody.create(MediaType.parse("text/plain"), email)); call.enqueue(new Callback<APIResults>() { @Override public void onResponse(retrofit.Response<APIResults> response, Retrofit retrofit) {
I call it this way: MainActivity
RequestHelper.checkEmailAvailability(" user@user.com ");
Now the function is still invalid, but I would like it to return something after the onResponse and onFailure .
Any thoughts please?
source share