0

I am using the Android Class CallScreeningService onScreenCall(Call.Details calldetails) to get all incoming calls and everything works fine! From now I have an error, that on Android 10 devices the function calldetails.getExras() and calldetails.getIntentExtras() always returns NULL, instead of a Bundle, where I can read some further information. On Android 9 devices and older everything works fine.

Someone has a similar issue? Here is the Source Code and some Declarations:

public class IncomingCallService extends CallScreeningService {

    @Override
    public void onScreenCall(Call.Details callDetails) {
                if (callDetails.getExtras() != null) {
                        Log.d(LOG_TAG, "Everything works on Android 9 or older");
                }else{
                        Log.d(LOG_TAG, "Its Null on Android 10!");
                }  

                if (callDetails.getIntentExtras() != null) {
                        Log.d(LOG_TAG, "Everything works on Android 9 or older");
                }else{
                        Log.d(LOG_TAG, "Its Null on Android 10!");
                }     
}

And Manifest.xml:

<service android:name=".call_handler.IncomingCallService"
    android:permission="android.permission.BIND_SCREENING_SERVICE">
     <intent-filter>
          <action android:name="android.telecom.CallScreeningService"/>
     </intent-filter>
</service>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

2 Answers2

1

According to Android docs:

Note: The Call.Details instance provided to a call screening service will only have the following properties set. The rest of the Call.Details properties will be set to their default value or null.

Call.Details#getCallDirection()

Call.Details#getConnectTimeMillis()

Call.Details#getCreationTimeMillis()

Call.Details#getHandle()

Call.Details#getHandlePresentation()

Only calls where the Call.Details#getHandle() Uri#getScheme() is PhoneAccount#SCHEME_TEL are passed for call screening. Further, only calls which are not in the user's contacts are passed for screening. For outgoing calls, no post-dial digits are passed.

So what you are seeing it's just the expected behavior for Android 10.

greywolf82
  • 21,813
  • 18
  • 54
  • 108
0

On Androind 29+ you need user permission :

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
        RoleManager roleManager = (RoleManager) getSystemService(ROLE_SERVICE);
        Intent intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_CALL_SCREENING);
        startActivityForResult(intent, 1);
    }
Stav Bodik
  • 2,018
  • 3
  • 18
  • 25