I am trying to make a phone call in Android Studio with Kotlin; the objetive is to call the emergency telephone number "911" in Mexico. When I press the call button the app only show me the telephone number ("911" in the native app of the cellphone) instead of calling automatically. At the beginning I thought It was because of the "Intent", then I changed the number using "+" or "(52)44.." and It worked! I don´t know what could be the problem.
Permissions:
<uses-permission android:name="android.permission.CALL_PHONE"/>
Code:
imageLlamada.setOnClickListener({
makePhoneCall("911")
})
fun makePhoneCall(number: String) : Boolean {
try {
val intent = Intent(Intent.ACTION_CALL)
intent.setData(Uri.parse("tel:$number"))
startActivity(intent)
return true
} catch (e: Exception) {
e.printStackTrace()
return false
}
}