Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Call Phone Number In Kotlin Android [closed]

Tags:

android

kotlin

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

like image 592
J-rone Avatar asked Nov 29 '22 22:11

J-rone


2 Answers

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"/>
like image 147
TheTechWolf Avatar answered Dec 04 '22 01:12

TheTechWolf


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" />
like image 20
Ihab_zaidi Avatar answered Dec 03 '22 23:12

Ihab_zaidi