Android – How To Call Phone Number In Kotlin Android

android, kotlin

How can I make a phone call or dial a number in Android Kotlin? For example: Call *21*2#

Best Solution

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"/>