-1

This is the openexchangerate from where I want to parse the EUR Rate
image

@Override
protected Void doInBackground(Void... voids) {
    try {
        String uRl = "https://openexchangerates.org/api/latest.json?app_id=9d60a61dd1914783b037cc5835ee9829&symbols=EUR";
        JSONObject reader = new JSONObject(uRl);
        JSONObject sys = reader.getJSONObject("rates");
        EUR = sys.getString("EUR");
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return null;
}

@Override
protected void onPostExecute(Void aVoid) {
    progressDialog.dismiss();
    textView.setText(EUR);
}

This is my code to parse the EUR Rate. I used a simple textview in xml to display the rate. But nothing is getting displayed in the emulator. Could someone please help me where I am making mistake?

Screenshot of my emulator
image

Andreas
  • 154,647
  • 11
  • 152
  • 247
  • Could someone please help me with this issue? Please forgive me if my description is not clear or not understandable. I started learning android studio only during this lockdown and new to stack overflow. – Arun Pandian Jul 07 '20 at 21:47

1 Answers1

0

The point is you're trying to parse the API URL to JSON object, instead of the API response. You should call the API first, then parse the API response to JSON object. A similar problem has been solved here: Use JSON API in Java

Hope this is helpful.

Minh Duy
  • 127
  • 5