Hello everyone,
According from :
rest - How to make a synchronous call using Retrofit on Android - Stack Overflow[
^]
if I use retrofit2 synchronously would make app crash, but I really need something that could
return the value directly.
What I have tried:
I've ever used asycntask like this :
public static class GetData extends AsyncTask<Void, Void, String> {
@Override
protected String doInBackground(Void... vd) {
RequestHandler requestHandler = new RequestHandler();
HashMap<String, String> params = new HashMap<>();
params.put("user_id", "1");
return requestHandler.sendPostRequest(URLs.GET_VIDEOS, params);
}
@Override
protected void onPostExecute(String vdata){
super.onPostExecute(vdata);
}
}
this could be return value directly when I call :
new GetData().execute().get();
Note : I've ever used volley also, but volley incompatible with laravel, the result always GET never POST.
Q : Is there other solutions to get value data directly besides using
asynctask?
I don't want to using
asynctask because it caused my app slow.
Please someone help me
Thanks