Reputation: 150
I am making an app that programmatically accepts an incoming call without being the default calling application. It has been easier to achieve in Android 9 and below with tm.acceptRingingCall()
and tm.endCall
. Unfortunately these methods have been deprecated starting Android 10. According to documentation it can be done using the InCallService
API. But is it possible to do that without being the default calling app?
Upvotes: 4
Views: 4415
Reputation: 150
Unfortunately, the answer is no. From Android 10 onwards the only way to handle phone calls is by using the InCallService
APIs. I have made a basic dialer app in java that explains basics of how to handle calls as a default dialer app (link: https://github.com/adnan-creator/java-custom-dialer). So for now the best solution is to be the default dialer app till you need the functionality of programmatically accepting or rejecting calls. Then you can transfer the controls back to the inbuilt dialer app.
This can be done by initially storing the package name of the inbuilt dialer before taking control using
telecomManager.getDefaultDialerPackage()
.
The control can then be passed back to the inbuilt dialer app
Intent intent = (new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER))
.putExtra(
TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME,
storedPackageName);
this.startActivityForResult(intent, REQUEST_CODE_SET_DEFAULT_DIALER);
Upvotes: 6