You can use this 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&to=EUR&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;
}
API_Rate_Model Class :
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;
}
}
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 :)