Hello everyone, I'm developing an android application that uses the volley library (google) to perform my http requests. I have a method that returns a Boolean and depends on the return of the request, then that is the badness, the method returns the value before finishing the request.
public class MyService implements IMyService {
private Context context = null;
private Boolean result = false;
public MyService(Context context){
this.context = context; Thread
}
@Override
public Boolean isUrlValida(final String url){
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener<String>() {
@Override
public void onResponse(String s) {
result = true;
Log.w("isUrlValida", "onResponse");
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.w("isUrlValida", "onErrorResponse");
}
}
);
((AppApplication) context).getRequestQueue().add(stringRequest);
((AppApplication) context).getRequestQueue().start();
return result;
}
}
Will I need to do any Thread's control? Thanks!