如何绑定CallScreeningService? [英] How to bind CallScreeningService?
问题描述
我想获取通话详细信息"并阻止通话(如有必要).由于不赞成使用TelecomManager endCall方法,并且根据文档,建议使用CallScreeningService. https://developer.android.com/reference/android/telecom/CallScreeningService.html
I want to get the Call Details and block the calls(if necessary). As the TelecomManager endCall method is deprecated and as per the documentation it is suggesting to use the CallScreeningService. https://developer.android.com/reference/android/telecom/CallScreeningService.html
如Android文档中所述,我正在尝试将CallScreeningService与我的应用程序绑定.
As mentioned in the Android documentation, I am trying to bind the CallScreeningService with my application.
我创建了一个课程
public class CallUtil extends CallScreeningService {
private Call.Details mDetails;
private static CallScreeningUtil sCallScreeningUtil;
@Override
public void onScreenCall(Call.Details callDetails) {
CallResponse.Builder response = new CallResponse.Builder();
Log.e("CallBouncer", "Call screening service triggered");
sCallScreeningUtil = this;
mDetails = callDetails;
respondToCall(callDetails, response.build() );
}
}
这是一个系统应用程序,我已经在AndroidManifest.xml中添加了必要的权限,例如CALL_PHONE,MODIFY_PHONE_STATE,CALL_PHONE,ANSWER_PHONE_CALLS.
This is a system app and I have added necessary permission in AndroidManifest.xml such as CALL_PHONE, MODIFY_PHONE_STATE, CALL_PHONE, ANSWER_PHONE_CALLS.
我还添加了以下服务详细信息,
I have added the Service details as well like below,
<service android:name=".CallUtil"
android:permission="android.permission.BIND_SCREENING_SERVICE">
<intent-filter>
<action android:name="android.telecom.CallScreeningService"/>
</intent-filter>
</service>
对于如何将此服务与我的活动绑定或如何将该应用程序与将在CallUtil中调用Overridden方法的应用程序绑定,我有点迷茫.
I am kinda lost on how to bind this service with my activity or how do I bind this service with my application that will call the Overridden methods in CallUtil.