I know you can use Intent.ACTION_DIAL to bring up the dialer with the supplied phone number.
But how do you make the actual call from an app, i know theres and Intent.ACTION_CALL.
here my code of a simple app enter the phone number and press the button to place the call
Code:
package com.grimx.MakeCall;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MakeCall extends Activity implements View.OnClickListener{
EditText editText;
Button callBtn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
editText = (EditText)findViewById(R.id.editText);
callBtn = (Button)findViewById(R.id.callBtn);
callBtn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if(v.getId() == R.id.callBtn) {
String phn_number = editText.getText().toString();
if(!phn_number.equals("")) {
Intent dial_intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phn_number));
startActivity(dial_intent);
Intent call_intent = new Intent(Intent.ACTION_CALL); //not sure how to implement this action
startActivity(call_intent);
}
}
}
}
my layout
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText
android:id="@+id/editText"
android:phoneNumber="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/callBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Call"
/>
</LinearLayout>