Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use this code : </p> <pre><code>public API_Rate_Model getRate() { API_Rate_Model result = new API_Rate_Model(); try { HttpResponse response; HttpClient myClient = new DefaultHttpClient(); HttpPost myConnection = new HttpPost("http://rate-exchange.appspot.com/currency?from=USD&amp;to=EUR&amp;q=1"); try { response = myClient.execute(myConnection); String JSONString = EntityUtils.toString(response.getEntity(), "UTF-8"); Log.i(BaseID.TAG, JSONString); JSONObject json = null; json = new JSONObject(JSONString); result.setTo(json.getString("to")); result.setRate(json.getDouble("rate")); result.setFrom(json.getString("from")); result.setValue(json.getDouble("v")); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } return result; } </code></pre> <p>API_Rate_Model Class :</p> <pre><code>public class API_Rate_Model { private String to; private Double rate; private String from; private Double value; public API_001_Model() { to = ""; rate = 0.0; from = ""; value = 0.0; } public Double getRate() { return rate; } public void setRate(Double rate) { this.rate = rate; } public int getValue() { return value; } public void setValue(Double value) { this.value = value; } public String getFrom() { return from; } public void setFrom(String from) { this.from = from; } public String getTo() { return to; } public void setTo(String to) { this.to= to; } } </code></pre> <p>this code will sent a post to the server then convert the response to string then process the JSON String response. I hope my answer can helps you, but if you have any question feel free to ask in the comment :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload