Thursday 15 March 2012

java - Currency Converter API not working in Android -


I am facing a problem where my Yahoo Finance API is not working in my code. I am making a realtime currency converter. I've investigated Google but nothing is answering my question. When I press the "Count" button in my app, nothing happens here I have the code given.

  Public Interface CurrencyConverter {Public Double Convert (string currency, from string currency) throws exceptions; } Implements public class YahooCurrencyConverter CurrencyConverter {public double convert (String currency, the currency string) throws IOException {HttpClient httpclient = new DefaultHttpClient (); HttpGet httpGet = new Actiteepiajit ( "http://quote.yahoo.com/d/quotes.csv?s=" + Mudraaman + currency "+" = x and F = L 1 and A =. Sisivi "); ResponseHandler & LT; string & gt; Pratikriyahandlr = new Besikareshnshandlr (); string Pratikriyabodi = httpclient.execute (httpGet, Pratikriyahandlr);. HttpclientkgetConnectionManager () (closed); return double. Piarsdbl (Pratisadbeedi);}} public void Knhwartdolarstouros () {Double-on- double val = double. Prsd double (edittextdollars.getText (). ToString ()); decimalff df = New Dsmlvfl ( ". ##"); YahooCurrencyConverter ycc = new YahooCurrencyConverter (); {Current = ycc.convert ( "USD", "EUR") try; edittexteuros.setText (df.format (VAL * current)) ;} catch (exception e) {e.printStackTrace ();}}   

allow internet I have manifest file and I founded Google API in your Android SDK. my code Something is wrong, but I can not recognize it. When I remove the try / hold method, then what is this: Http://oi40.tinypic.co M / 2sah6d5 Any help would be greatly appreciated. </ P> </ div> <p> <div class =

Most of the " Nothing happens "because you are catching all the exceptions, I recommend that you remove block ... block, or at least specific hold exceptions Those that you need to handle, and the Java exception system, the rest of the work for you, I firmly recommend that you use Java exception handling system. A great place is the first two stories to introduce more rays which will give you the basic things you should know about the 99% of you Android programming.

Also, you would see that there Exception is is thrown.

Edit: A little about exceptions

Note that in some text popup messages blue That means you can click on it and you can click on it Sector will generate some code I suggest that you went out on the sea "with the" Tour / catch and note that generates the code that you enter here posted is different. This is a great tool to use when you understand how to try / catch details are used.

In this special case, I think "Add Throwing Announcement" is a better option. Click on it and see what happens that you will get the most such errors elsewhere in your code. You should keep declaration in every method that does not know to deal with the exception. You should only add an attempt / hold statement in the method that knows what to do when there is an error. It usually occurs in the UI code such as the listener method.

No comments:

Post a Comment