Category: Uncategorized
Money Converter
Here we are talking money converter.This Money converter is an android application which is an efficient application to convert currency of different countries in nowadays. Base currency used here is Euro.firstly User need to enter an euro value and select the country which they need to change to and click the converter button. then we can values,we like

package com.mbwasi.chaching;
import org.json.JSONException;
import org.json.JSONObject;
import com.actionbarsherlock.app.SherlockActivity;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends SherlockActivity {
private static final String API_URL = “https://api.exchangeratesapi.io/latest”;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btnDoit = (Button)findViewById(R.id.buttonDoit);
final EditText usdValue = (EditText) findViewById(R.id.editText1);
final TextView eurValue = (TextView) findViewById(R.id.editText2);
btnDoit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
if (!usdValue.getText().toString().equals(“”)) {
AsyncHttpClient client = new AsyncHttpClient();
client.get(API_URL, new AsyncHttpResponseHandler() {
@Override
public void onFailure(Throwable arg0, String arg1) {
super.onFailure(arg0, arg1);
}
@Override
public void onFinish() {
super.onFinish();
}
@Override
public void onStart() {
super.onStart();
}
@Override
public void onSuccess(String response) {
Log.i(“CHACHING”, “HTTP Sucess”);
try {
JSONObject jsonObj = new JSONObject(response);
JSONObject ratesObject = jsonObj
.getJSONObject(“rates”);
Double eurRate = ratesObject.getDouble(“Country”);
Log.i(“CHACHING”, “Country: ” + eurRate);
Double usds = Double.valueOf(usdValue
.getText().toString());
Double euros = usds * eurRate;
eurValue.setText(“EURO: “
+ String.valueOf(euros));
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}else {
Toast.makeText(getApplicationContext(),
“Please enter a Euro value!”,
Toast.LENGTH_LONG).show();
}
}
The Journey Begins
Thanks for joining me!
Good company in a journey makes the way seem shorter. — Izaak Walton
