How to run a built-in call app when a device gets incoming call in onCallAdded(InCallService) function?

554 Views Asked by At

When a phone is ringing ( by an incoming call) If the phone number is a specific number I want to show my custom UI. If It is not, I want to pass it to the (built-in) system call app(Or any other call app is okay).

I should use 'InCallService' and the device set my app as 'a default call app' so that even when the phone screen is locked my custom-UI-activity be shown. The following kotlin source code is my goal.

override fun onCallAdded(call: Call) {  
    //app should receive a new incoming call via 'onCallAdded'

    super.onCallAdded(call)

    val phoneNumber = getPhoneNumber(call)
    if (isMyTargetNumber(phoneNumber)) {
        //show my custom UI
    } else {
        //run a built-in call app
    }
}

The problem that I want to solve is how to run a built-in call app appropriately. I mean I want to complete to wirte the blank of 'else'

    else {
        //run a built-in call app
    }

Apps on the android market like 'truecaller' or 'whosecall' works well the way I want to acheive. I want to make my app such apps. Please help me and advise something to me.

0

There are 0 best solutions below