如何绑定CallScreeningService? [英] How to bind CallScreeningService?

本文介绍了如何绑定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.

推荐答案

基于此处提供的文档

从活动中绑定到可以使用的服务

And from an activity, to bind to the service you can use

bindService(mCallServiceIntent, mServiceConnection, Context.BIND_AUTO_CREATE)

这篇关于如何绑定CallScreeningService?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆