How can I make a phone call or dial a number in Android Kotlin? For example: Call *21*2#
If you are using Anko library you could simple call this function
makeCall(number)
Link for Anko library.
If you are not using this library, then do this:
val intent = Intent(Intent.ACTION_CALL);
intent.data = Uri.parse("tel:$number")
startActivity(intent)
Don't forget to add permission to your manifest:
<uses-permission android:name="android.permission.CALL_PHONE"/>
this is a java example :
On call button click:
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + "Your Phone_number"));
startActivity(intent);
Permission in Manifest:
<uses-permission android:name="android.permission.CALL_PHONE" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With