Up to Android 9 included, my app could call a number without human intervention.
With the update to Android 10 the call is made after the user exists the application.
This is the function making the call:
/**
* Call the given number if no other call is busy.
*
* @param number Number to call
*/
private void callNumber(String number) {
if(!Utils.isCallActive()) {
// ACTION_CALL: Direct call
this.startIntent(new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+number)));
}
}
The related permission is requested from the user and enabled:
<uses-permission android:name="android.permission.CALL_PHONE" />
The developer documentation does not suggest to do anything else: https://developer.android.com/guide/components/intents-common#DialPhone
Prior to that, the application has been brought to the front in an activity (an incoming push wakes up the app which triggers this behavior).
I wonder if that could have an impact:
orgFlags=window.getAttributes().flags;
window.addFlags(
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
);
For applications handling the outgoing call, ACTION_NEW_OUTGOING_CALL is deprectated, but I do not see how this should impact the application requesting the call.
I'll be testing if call finish on the current activity helps.
In the end the question is: How to ensure that an application can trigger a direct outgoing call without human interaction in Android 10?
Calling
finish()
on the running activity enables the "direct call" triggered using thestartIntent(...)
call prior to callingfinish()
.Edit: Unfortunately this is not a perfect fix: it does not work in all cases.