val dialerIntent = Intent()
val et = findViewById(R.id.some_edit_text)
dialerIntent.action = Intent.ACTION_DIAL
dialerIntent.data = Uri.parse("tel:" + et.getText()?.toString())
startActivity(dialerIntent)
-
startActivityWithResult()
should be used instead ofstartActivity()
when usingIntent.ACTION_DIAL
. - For
Intent.ACTION_DIAL
, theIntent
optionIntent.FLAG_ACTIVITY_NEW_TASK
must be added when using thisdialerIntent
. - The
dialerIntent
will cause an ActivityNotFoundException to be thrown on devices that do not supportIntent.ACTION_DIAL
. - The permission
android.permission.CALL_PHONE
must be requested first beforeIntent.ACTION_DIAL
can be used.