I am trying to add CallScreeningService in my android application(targetSdkVersion 29) without making my app a caller app. I follow all the instructions but still not getting it properly OR missing something there. Here is my code:
public class CallAppService extends CallScreeningService {
@Override
public void onScreenCall(Call.Details callDetails) {
Log.e("CallBouncer", "Call screening service triggered");
respondToCall(callDetails, new CallScreeningService.CallResponse.Builder().setDisallowCall(true).setRejectCall(true).build());
}
}
<service android:name="com.myapp.service.CallAppService" android:permission="android.permission.BIND_SCREENING_SERVICE">
<intent-filter>
<action android:name="android.telecom.CallScreeningService"/>
</intent-filter>
</service>
Added following permission:
<uses-permission android:name="android.Manifest.permission.READ_CONTACTS"/>
<uses-permission android:name="android.Manifest.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.Manifest.permission.READ_CALL_LOG"/>
<uses-permission android:name="android.Manifest.permission.PROCESS_OUTGOING_CALLS"/>
<uses-permission android:name="android.Manifest.permission.ANSWER_PHONE_CALLS"/>
But still that this service is not invoking when I do a call. Is there anything that I am missing? I also see this issue but not getting the idea that why we need a ServiceConnection as it is not mentioned in the documentation.