0
I have an application that gets given via api using Volley
My code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tela1);
ImageView myImageView = (ImageView) findViewById(R.id.imageView);
myImageView.setImageResource(R.drawable.imagem);
requestQueue = Volley.newRequestQueue(this);
results = (TextView) findViewById(R.id.textView2);
datav = (TextView) findViewById(R.id.textA);
JsonArrayRequest arrayreq = new JsonArrayRequest(JsonURL,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
try {
JSONObject obj = response.getJSONObject(0);
Double ask = obj.getDouble("ask");
String data = obj.getString("create_date");
results.setText("Vale R$: " + ask);
datav.setText("Atualizado em: " + data);
} catch (JSONException e) {
e.printStackTrace();
}}},
new Response.ErrorListener() {
@Override
// Handles errors that occur due to Volley
public void onErrorResponse(VolleyError error) {
Log.e("Volley", "Error");
}
}
);
I want to pass the value of "Ask" which is received to another screen, how do I do this?
I can only get the value of "Ask" from inside: @Override public void onResponse(Jsonarray Response) { Try { } in this case as it would be?
– denis
then you’ll do the same thing, only inside the onResponse.
– Shogogan