Getting Started with Android. Simple Dialer

private void call() {
		System.out.println("Dial");

		// 1. First take out the EditText number
		editText = (EditText) findViewById(R.id.number);
		Intent intent = new Intent();
		String number = editText.getText().toString();// Get the phone number

		// make a call based on the number
		intent.setAction(Intent.ACTION_CALL);// Specify the action of Intent as call, make a call
		intent.setData(Uri.parse("tel:" + number));// Specify the data of the Intent as the dialed phone number
		startActivity(intent);
	}

	@Override
	public void onClick(View v) {
		System.out.println("Dial number!!!");
		call();
	}

androidManiFest.xml add

 <!-- Add permission to make calls-->>
    <uses-permission android:name="android.permission.CALL_PHONE"/>



Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326994366&siteId=291194637