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 of startActivity() when using Intent.ACTION_DIAL.
  •  For Intent.ACTION_DIAL, the Intent option Intent.FLAG_ACTIVITY_NEW_TASK must be added when using this dialerIntent.
  •  The dialerIntent will cause an ActivityNotFoundException to be thrown on devices that do not support Intent.ACTION_DIAL.
  •  The permission android.permission.CALL_PHONE must be requested first before Intent.ACTION_DIAL can be used.

By Neha S

Leave a Reply

Your email address will not be published. Required fields are marked *