Most visited

Recently visited

Added in API level 24

CallScreeningService

public abstract class CallScreeningService
extends Service

java.lang.Object
    android.content.Context
      android.content.ContextWrapper
        android.app.Service
          android.telecom.CallScreeningService


该服务可以通过默认拨号程序(请参阅 getDefaultDialerPackage() )实现,以允许或禁止向用户显示来电。

以下是一个 CallScreeningService清单注册 CallScreeningService

 <service android:name="your.package.YourCallScreeningServiceImplementation"
          android:permission="android.permission.BIND_SCREENING_SERVICE">
      <intent-filter>
          <action android:name="android.telecom.CallScreeningService"/>
      </intent-filter>
 </service>
 
 

摘要(Summary)

Nested classes

class CallScreeningService.CallResponse

 

常量(Constants)

String SERVICE_INTERFACE

必须声明为由服务处理的 Intent

Inherited constants

From class android.app.Service
From class android.content.Context
From interface android.content.ComponentCallbacks2

Public constructors

CallScreeningService()

公共方法(Public methods)

IBinder onBind(Intent intent)

将通信信道返回给服务。

abstract void onScreenCall(Call.Details callDetails)

在添加新的来电时调用。

boolean onUnbind(Intent intent)

当所有客户端与服务发布的特定接口断开连接时调用。

final void respondToCall(Call.Details callDetails, CallScreeningService.CallResponse response)

响应给定的呼叫,允许或不允许呼叫。

继承方法(Inherited methods)

From class android.app.Service
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks2
From interface android.content.ComponentCallbacks

常量(Constants)

SERVICE_INTERFACE

Added in API level 24
String SERVICE_INTERFACE

必须声明为由服务处理的 Intent

常量值:“android.telecom.CallScreeningService”

Public constructors

CallScreeningService

Added in API level 24
CallScreeningService ()

公共方法(Public methods)

onBind

Added in API level 24
IBinder onBind (Intent intent)

将通信信道返回给服务。 如果客户端无法绑定到服务,可能会返回null。 返回IBinder通常是一个复杂的界面已经described using aidl

请注意,与其他应用程序组件不同,此处返回的IBinder接口调用可能不会发生在进程的主线程上 有关主线程的更多信息可以在Processes and Threads中找到。

参数(Parameters)
intent Intent: The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.
返回(Returns)
IBinder Return an IBinder through which clients can call on to the service.

onScreenCall

Added in API level 24
void onScreenCall (Call.Details callDetails)

在添加新的来电时调用。 应该调用respondToCall(Call.Details, CallScreeningService.CallResponse)来允许或禁止呼叫。

参数(Parameters)
callDetails Call.Details: Information about a new incoming call, see Call.Details.

onUnbind

Added in API level 24
boolean onUnbind (Intent intent)

当所有客户端与服务发布的特定接口断开连接时调用。 默认实现什么也不做,并返回false。

参数(Parameters)
intent Intent: The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.
返回(Returns)
boolean Return true if you would like to have the service's onRebind(Intent) method later called when new clients bind to it.

respondToCall

Added in API level 24
void respondToCall (Call.Details callDetails, 
                CallScreeningService.CallResponse response)

响应给定的呼叫,允许或不允许呼叫。

参数(Parameters)
callDetails Call.Details: The call to allow.
response CallScreeningService.CallResponse: The CallScreeningService.CallResponse which contains information about how to respond to a call.

Hooray!