Get current exchange rates automatically using the currency converter?

I am creating a currency converter application. I know that the value of currencies is constantly changing, so I was wondering if there is a way to access the Internet in my application in order to get current rates and easily include them in the application?

Thanks.

Update

I think my question is a little misunderstood. Getting the actual current exchange rates is not difficult for me; the hard part of writing code for this. Can someone put me in the right direction and help me understand how to write code to include them in the application?

+4
source share
3 answers

I am doing exactly what you are doing, although my main goal is to write a tutorial for the same. This is a good place from where you can get all exchange rate information.

http://josscrowcroft.github.com/open-exchange-rates/

They update data every hour and return information in json format.

Good luck :)

Update to UPDATE

Ok, so you need to read the following things and include them in your code,

  • Data retrieval can be done either by the HttpUrlConnection / Apache Http Client. (Make sure that you complete all your long-term tasks, that is, upload data to a separate stream).
  • Most of the returned data is usually received as XML or JSON. You need to write parsers using the classes present in Android. XmlPullParser / Dom Parser for XML or JSONObjects for JSON. For this, there is enough information on the Android developer site.
  • As soon as you analyze the data, you do not think or imagine that it is completely up to you.

Hope this helps you move forward.

+3
source

Yahoo Finance will return this information to you quite easily. I can not guarantee that they will provide this forever, but it seems that they have worked for years.

You simply use the following URL, and for each currency you want to convert, you put it in the URL, as in this example:

http://download.finance.yahoo.com/d/quotes.csv?s=USDEUR=x,JPYCNY=x&f=l1

This will return a CSV of $ 1 in Euros (USDEUR = x) and 1 Japanese Yen in Yuan Renminbi (JPYCNY = x).

Just a comma limits each pair of currencies for which you want to get a result.

You can also get more information by adding some extra characters to the & f part, although I don't have them. You should be able to search for codes.

+1
source

If you are looking for an idea, leave in your country, get your rates on the national bank. Look for any channels, if any, otherwise try to analyze their tariff table on the site. This reasoning is based on my assumption that such a site exists. Re-request this site each time you launch the application and connect to the Internet.

If you focus on international use, try to find reliable sources from where you will file this information.

If you are looking for an HTML parser library, run JSoup.

0
source

Source: https://habr.com/ru/post/1402044/


All Articles