How do I return this String reponse? If I give the return there it does not accept ... and if and by at the end of the method and using an auxiliary variable it risks returning null.
public String getData(){
StringRequest request = new StringRequest(
Request.Method.POST,
Config.urlMaster,
new Response.Listener<String>(){
@Override
public void onResponse(String response) {
JSONArray array;
try {
array = new JSONArray(response.toString());
String json = array.getJSONObject(0).toString();
Log.i("Script", "SUCCESS: "+response);
//return response;
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(contexto, "Error: "+error.getMessage(), Toast.LENGTH_LONG).show();
}
}){
};
request.setTag("tag");
requisicao.add(request);
return null;
}