I am trying to dial a user from my app launching the dialer in android
I have provided the manifest permission:
<uses-permission android:name="android.permission.CALL_PHONE"/>
I have also provided the runtime permission
Code:
private fun startPhoneDial(phoneNo: String) {
val callIntent = Intent(Intent.ACTION_CALL)
//callIntent.data = Uri.parse(phoneNo)
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
callIntent.setPackage("com.android.phone")
}else{
callIntent.setPackage("com.android.server.telecom")
}
callIntent.data = Uri.parse("tel:$phoneNo")
startActivity(callIntent)
}
Error-Stack-Trace:
Exception: Method threw 'android.content.ActivityNotFoundException' exception.
Message: No Activity found to handle Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxx pkg=com.android.phone }