How to intent dialer call from service?


I am using this this dialer example as basement. I have added some service(foreground) from where i should dial a call. How can i make it?

I have this in Service(onStartCommand)

    if (checkSelfPermission(this, CALL_PHONE) == PERMISSION_GRANTED) {
        val uri = "SOMENUMBER".toUri()
        startActivity(Intent(Intent.ACTION_CALL, uri).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))

But i does not work in service. Error log:

Process: *.*.*, PID: 2789
java.lang.RuntimeException: Unable to start service *.*.*.*.Service@ab2ea53 with Intent { cmp=*.*.*/.*.Service (has extras) }: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.CALL dat=PHONENUMBER flg=0x10000000 }

What should i do to make it work? And which ways are more right(if mays>1)?

asked on Stack Overflow Oct 30, 2019 by Cacarilo

1 Answer



should be


Input: If nothing, an empty dialer is started; else getData() is URI of a phone number to be dialed or a tel: URI of an explicit phone number.

Other related questions:

Call intent in Android

Android Intent.ACTION_CALL, Uri

answered on Stack Overflow Oct 30, 2019 by Blundell

User contributions licensed under CC BY-SA 3.0