anko icon indicating copy to clipboard operation
anko copied to clipboard

makeCall() not working

Open TBCode523 opened this issue 6 years ago • 1 comments

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())

                }
            }

TBCode523 avatar Oct 07 '18 03:10 TBCode523

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
    }
}

iceboundrock avatar Dec 19 '18 00:12 iceboundrock