package com.samples.telephony.phonecall;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class PhoneCallActivity extends Activity implements OnClickListener{

	private EditText textNumber;
	private Button bCall;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
		textNumber=(EditText)findViewById(R.id.textNumber);		
		bCall = (Button)findViewById(R.id.bCall);
		
		bCall.setOnClickListener(this);
	}

	@Override
	public void onClick(View arg0) {
		try {
			Uri uri = Uri.parse("tel:" + textNumber.getText().toString());
			startActivity(new Intent(Intent.ACTION_DIAL, uri));
			//startActivity(new Intent(Intent.ACTION_CALL_BUTTON));
		}
		catch (Exception e) {
			Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
		}	
	}
}