Hi and welcome to another tutorial from CodingDemos :)
In this tutorial, you will learn how to make a phone call by clicking on a button.
You will learn how to use the Android ACTION_DIAL Intent to be able to make the phone call from your app.
Here are the steps:
1- Open up Android Studio.
2- Inside Button onClickListener declare Android ACTION_DIAL Intent like this.
Intent intent = new Intent(Intent.ACTION_DIAL);
3- Next, you need to set the phone that you want to initiate the call. You will use intent.setData() like this.
intent.setData(Uri.parse("tel:123456789"));
Note: Please make sure that you add "tel:" before the actual phone number. Otherwise, the app will crash.
4- The last step is to start the Intent like this.
startActivity(intent);
5- Now build and run the app to see the result :)
Links:
Android ACTION_DIAL Intent: https://developer.android.com/referen...
Website: https://www.codingdemos.com
FaceBook: / codingdemos