'android studio withdrawal process of current bitcoin rates

https://api.coingecko.com/api/v3/simple/price?ids=0x%2Czcoin%2Cicon%2Cbitcoin%2Cethereum&vs_currencies=usd

I want to pull the current exchange rates from the json file I will get from this link and place them in a textview in android studio.

public class HomeActivity extends AppCompatActivity {

private TextView mTextViewResult;
private RequestQueue mQueue;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);

    mTextViewResult = findViewById(R.id.yazi1);

    mQueue = Volley.newRequestQueue(this);

    jsonParse();
}

private void jsonParse(){
    String url = "https://api.coingecko.com/api/v3/simple/price?ids=0x%2Czcoin%2Cicon%2Cbitcoin%2Cethereum&vs_currencies=usd";

    JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    try {
                        Log.w("Bitcoin",
                                "Response => " + response.toString());
                        
                        /*mTextViewResult.append(response.getJSONObject("bitcoin").getString("usd") + " U$D");

                        JSONArray jsonArray = response.getJSONArray("bitcoin");
                        JSONObject btc = jsonArray.getJSONObject(0);
                        mTextViewResult.append(btc.getString("USD"));

                        mTextViewResult.append(response.getJSONObject("bitcoin").toString());
                        
                        I'm not sure what to write here
                        */


                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            error.printStackTrace();
        }
    });
    mQueue.add(request);
}

}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source