How can I get the updated value of the dollar in android studio? [closed]

-4

I'm new to android studio and I can not figure out how to do it. On my PC I wrote a Bash script that does what I need:

#!/bin/sh
wget www.bna.com.ar -O bna 2> /dev/null
cat bna | grep td | grep [0-9][0-9]\.[0-9][0-9][0-9][0-9]| head -2 | tail -1 | cut -d\> -f2 | cut -d\< -f1 | sed 's/,/./' > dolar.txt
rm bna
cat dolar.txt

How could I implement this in Android Studio?

    
asked by Pablo Saquilán 04.05.2018 в 00:07
source

1 answer

1

You can use this page: link

to use your api you have to use something like this: link

that returns: {"EUR_USD":1.199058}

If you want it in Argentine pesos for example, it would be: link

And well, to implement it in the app, you can use volley (a library to make http requests). You can perform the following tutorial: Make Http Requests With The Volley Bookstore On Android . But basically it's this:

String URL_BASE = "http://free.currencyconverterapi.com/api/v5/convert?q=USD_ARS&compact=ultra";
jsArrayRequest = new JsonObjectRequest(
    Request.Method.GET,
    URL_BASE,
    null,
    new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            //Aquí haces el manejo de la respuesta...
        }
    },
    new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.d(TAG, "Error Respuesta en JSON: " + error.getMessage());

        }
    }
);
    
answered by 04.05.2018 в 00:28