public abstract class ConnectionService
extends Service
| java.lang.Object | ||||
| android.content.Context | ||||
| android.content.ContextWrapper | ||||
| android.app.Service | ||||
| android.telecom.ConnectionService | ||||
一种抽象服务,应该由任何可以拨打电话(VoIP或其他)的应用程序实现,并且希望将这些呼叫集成到内置的电话应用程序中。 一旦实施, ConnectionService需要两个额外的步骤,才能将其集成到手机应用程序中:
1. 在AndroidManifest.xml中注册
<service android:name="com.example.package.MyConnectionService"
android:label="@string/some_label_for_my_connection_service"
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE">
<intent-filter>
<action android:name="android.telecom.ConnectionService" />
</intent-filter>
</service>
2. 注册PhoneAccount与TelecomManager 。
有关更多信息,请参阅PhoneAccount和registerPhoneAccount(PhoneAccount) 。
一旦用户在电话应用程序设置中注册并启用,电信将绑定到ConnectionService实施,当它要求ConnectionService拨打电话或该服务已通过addNewIncomingCall(PhoneAccountHandle, Bundle)表明有来电时。 然后, ConnectionService可以预期致电onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)或onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)其中它应该提供Connection对象的新实例。 正是通过这个Connection对象,电信接收状态更新并且ConnectionService接收诸如应答,拒绝,保持和断开的呼叫命令。
当不再有实时通话时,电信将从 ConnectionService解除绑定。
常量(Constants) |
|
|---|---|
String |
SERVICE_INTERFACE 必须声明为由服务处理的 |
Inherited constants |
|---|
android.app.Service
|
android.content.Context
|
android.content.ComponentCallbacks2
|
Public constructors |
|
|---|---|
ConnectionService() |
|
公共方法(Public methods) |
|
|---|---|
final void |
addConference(Conference conference) 添加新的电话会议。 |
final void |
addExistingConnection(PhoneAccountHandle phoneAccountHandle, Connection connection) 添加由 |
final void |
conferenceRemoteConnections(RemoteConnection remoteConnection1, RemoteConnection remoteConnection2) 指示相关的 |
final RemoteConnection |
createRemoteIncomingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) 请求其他 |
final RemoteConnection |
createRemoteOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) 要求其他 |
final Collection<Conference> |
getAllConferences() 返回此 |
final Collection<Connection> |
getAllConnections() 返回此 |
final IBinder |
onBind(Intent intent) 将通信信道返回给服务。 |
void |
onConference(Connection connection1, Connection connection2) 会议两个指定的连接。 |
Connection |
onCreateIncomingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) 给定一个传入请求,创建一个 |
Connection |
onCreateOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) 给出一个输出请求,创建一个 |
void |
onRemoteConferenceAdded(RemoteConference conference) 表示已为现有的 |
void |
onRemoteExistingConnectionAdded(RemoteConnection connection) 当远程添加现有连接时调用。 |
boolean |
onUnbind(Intent intent) 当所有客户端与服务发布的特定接口断开连接时调用。 |
继承方法(Inherited methods) |
|
|---|---|
android.app.Service
|
|
android.content.ContextWrapper
|
|
android.content.Context
|
|
java.lang.Object
|
|
android.content.ComponentCallbacks2
|
|
android.content.ComponentCallbacks
|
|
String SERVICE_INTERFACE
必须声明为由服务处理的 Intent 。
常量值:“android.telecom.ConnectionService”
void addConference (Conference conference)
添加新的电话会议。 当通过onConference(Connection, Connection)或其他方式显式请求创建电话会议时,连接服务应通过调用此方法提供Conference的实例。 此方法提供的电话会议将一直持续到会议实例调用destroy() 。
| 参数(Parameters) | |
|---|---|
conference |
Conference: The new conference object. |
void addExistingConnection (PhoneAccountHandle phoneAccountHandle, Connection connection)
添加由 ConnectionService创建的连接,并通知电信新连接。
| 参数(Parameters) | |
|---|---|
phoneAccountHandle |
PhoneAccountHandle: The phone account handle for the connection. |
connection |
Connection: The connection to add. |
void conferenceRemoteConnections (RemoteConnection remoteConnection1, RemoteConnection remoteConnection2)
向相关的 RemoteConnectionService表明应将指定的 RemoteConnection合并成电话会议。
如果会议请求成功,将调用方法 onRemoteConferenceAdded(RemoteConference) 。
| 参数(Parameters) | |
|---|---|
remoteConnection1 |
RemoteConnection: The first of the remote connections to conference. |
remoteConnection2 |
RemoteConnection: The second of the remote connections to conference. |
RemoteConnection createRemoteIncomingConnection (PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request)
请求其他ConnectionService根据给定的传入请求创建RemoteConnection 。 这由ConnectionService s使用,它们在CAPABILITY_CONNECTION_MANAGER中注册,并希望能够管理基于SIM卡的来电。
| 参数(Parameters) | |
|---|---|
connectionManagerPhoneAccount |
PhoneAccountHandle: See description at onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest). |
request |
ConnectionRequest: Details about the incoming call. |
| 返回(Returns) | |
|---|---|
RemoteConnection |
The Connection object to satisfy this call, or null to not handle the call. |
RemoteConnection createRemoteOutgoingConnection (PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request)
请求一些其他ConnectionService在给定传出请求的情况下创建RemoteConnection 。 这被ConnectionService所使用,它们在CAPABILITY_CONNECTION_MANAGER中注册并且希望能够使用基于SIM的ConnectionService来发出其呼出。
| 参数(Parameters) | |
|---|---|
connectionManagerPhoneAccount |
PhoneAccountHandle: See description at onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest). |
request |
ConnectionRequest: Details about the incoming call. |
| 返回(Returns) | |
|---|---|
RemoteConnection |
The Connection object to satisfy this call, or null to not handle the call. |
Collection<Conference> getAllConferences ()
返回此 ConnectionService已承担责任的所有活动 Conference 。
| 返回(Returns) | |
|---|---|
Collection<Conference> |
A collection of Conferences created by this ConnectionService. |
Collection<Connection> getAllConnections ()
返回此 ConnectionService已承担责任的所有活动 Connection 。
| 返回(Returns) | |
|---|---|
Collection<Connection> |
A collection of Connections created by this ConnectionService. |
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. |
void onConference (Connection connection1, Connection connection2)
会议两个指定的连接。 当用户请求合并指定的连接到电话会议中时调用。 作为响应,连接服务应该创建一个Conference的实例并将其传递到addConference(Conference) 。
| 参数(Parameters) | |
|---|---|
connection1 |
Connection: A connection to merge into a conference call. |
connection2 |
Connection: A connection to merge into a conference call. |
Connection onCreateIncomingConnection (PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request)
给定一个传入请求,创建一个Connection 。 这用于附加到现有的来电。
| 参数(Parameters) | |
|---|---|
connectionManagerPhoneAccount |
PhoneAccountHandle: See description at onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest). |
request |
ConnectionRequest: Details about the incoming call. |
| 返回(Returns) | |
|---|---|
Connection |
The Connection object to satisfy this call, or null to not handle the call. |
Connection onCreateOutgoingConnection (PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request)
给出一个传出请求创建一个Connection 。 这用于发起新的传出呼叫。
| 参数(Parameters) | |
|---|---|
connectionManagerPhoneAccount |
PhoneAccountHandle: The connection manager account to use for managing this call. 如果此参数不是 如果这个参数是 |
request |
ConnectionRequest: Details about the outgoing call. |
| 返回(Returns) | |
|---|---|
Connection |
The Connection object to satisfy this call, or the result of an invocation of createFailedConnection(DisconnectCause) to not handle the call. |
void onRemoteConferenceAdded (RemoteConference conference)
表示已为现有的RemoteConnection创建远程会议。 当这个方法被调用时,这个ConnectionService应该创建它自己的电话会议表示并使用addConference(Conference)发送给电信。
这只与在 ConnectionService注册的 CAPABILITY_CONNECTION_MANAGER 。
| 参数(Parameters) | |
|---|---|
conference |
RemoteConference: The remote conference call. |
void onRemoteExistingConnectionAdded (RemoteConnection connection)
当远程添加现有连接时调用。
| 参数(Parameters) | |
|---|---|
connection |
RemoteConnection: The existing connection which was added. |
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. |