I am using following code to register the service in Manifest.
<service android:name=".CallScreenService"
android:permission="android.permission.BIND_SCREENING_SERVICE">
<intent-filter>
<action android:name="android.telecom.CallScreeningService"/>
</intent-filter>
</service>
This is my service class that is extending the CallScreeningService.
@RequiresApi(api = Build.VERSION_CODES.N)
public class CallScreenService extends CallScreeningService {
@Override
public void onScreenCall(Call.Details callDetails) {
CallResponse.Builder response = new CallResponse.Builder();
Toast.makeText(this, callDetails.getHandle().toString(), Toast.LENGTH_LONG).show();
}
}
If you have implemented onStartCommand remove it. Remove onBind and onUnbind as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With