In some of the apps that we develop we may need to make a call through it. This could easily be done by using implicit Intent with appropriate actions.We can use Android Intent to make phone call by calling built-in Phone Call functionality of the Android.In my code i will be using ACTION_DIAL where we will be having option to modify hard coded phone number before making a call instead of making direct call.
Intent callIntent = new Intent(Intent.ACTION_DIAL, number);
Following code snippet shows how to use Android Intent to make phone call to the given mobile number.
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Button callbutton = (Button) findViewById(R.id.callbtn); callbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Uri number = Uri.parse("tel:0123456789"); Intent callIntent = new Intent(Intent.ACTION_DIAL, number); startActivity(callIntent); } }); } We need to add the following button code in xml: <Button android:id="@+id/callbtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="50dp" android:layout_marginTop="130dp" android:text="0123456789" />