anko
anko copied to clipboard
makeCall() not working
Hey guys I've been trying to find out why the makeCall() function doesn't work but I can't seem to figure it out! The code I have is the following: button("Call Me"){ onClick {
makeCall(numberText.toString())
}
}
Did you grant sufficient permissions to your app? makeCall
just starts an activity with Intent.ACTION_CALL
which needs android.permission.CALL_PHONE
. Here is the code:
fun Context.makeCall(number: String): Boolean {
try {
val intent = Intent(Intent.ACTION_CALL, Uri.parse("tel:$number"))
startActivity(intent)
return true
} catch (e: Exception) {
e.printStackTrace()
return false
}
}