3
How do I make the return of this String rest? If I give the Return there it does not accept... and if and at the end of the method and use an auxiliary variable runs the risk of returning a 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;
}
Related http://answall.com/q/150458/2541
– ramaral