Hello I am having issues getting Alpha Vantage api to work how I want. All I want to get is the last days close price. I am not exactly sure what I am doing wrong. A the moment my only goal is to simply change to TextView "tvStockClose" the last days close. The error right now is a run time error. Any help in any direction is appreciated and welcomed.
API: link
public void loadData() {
progressDialog.setMessage("Retrieving Data, Please Be Patient");
progressDialog.show();
Toast.makeText(getApplicationContext(), "1 :D", Toast.LENGTH_SHORT).show();
StringRequest stringRequest = new StringRequest(Request.Method.GET,
URL2,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Toast.makeText(getApplicationContext(), "2 :D", Toast.LENGTH_SHORT).show();
try {
Toast.makeText(getApplicationContext(), "3:D", Toast.LENGTH_SHORT).show();
mStockList.clear();
JSONObject jsonObject = new JSONObject(response);
String addThis = jsonObject.getJSONObject("20171102").getString("close");
tvStockClose.setText(addThis);
TestStockList testStockList = new TestStockList(addThis);
mStockList.add(testStockList);
Toast.makeText(StockTest.this, addThis, Toast.LENGTH_SHORT).show();
mAdapter = new TestMyAdapterStockList(mStockList, getApplicationContext());
recyclerView.setAdapter(mAdapter);
progressDialog.dismiss();
Toast.makeText(getApplicationContext(), "4 :D", Toast.LENGTH_SHORT).show();
} catch (JSONException e) {
//Toast.makeText(getContext(), "5 :D", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
progressDialog.dismiss();
Toast.makeText(getApplicationContext(), "6 :D", Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "Something Went Wrong, try Again", Toast.LENGTH_SHORT).show();
}
});
RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
requestQueue.add(stringRequest);
Toast.makeText(getApplicationContext(), "7 :D", Toast.LENGTH_SHORT).show();
}