我正试图用本指南实现与电信业务的互联:https://developer.android.com/guide/topics/connectivity/telecom/
我是已经可以显示自己的全屏来电用户界面没有电信服务,打和接收视频电话。所有,我想做的是电信服务,只是告诉Android操作系统,我们的应用程序是启动/停止视频通话的特定时刻,并从其他呼叫应用程序接收电话保持/未保留事件。
主要问题是:
1) addNewIncomingCall在接到呼叫时什么也不做: onCreateIncomingConnection回调没有启动(甚至连at的onCreate回调都没有启动)。为什么没有启动连接服务?
2)如果placeCall试图用用户id打开系统呼叫应用程序,将其作为电话或SIP号码呼叫。没有系统UI,我可以使用placeCall吗?
或者,如果我只是想通知系统有关视频通话,我可以使用其他选项,而不是TelecomService?
连接创建如下:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
connection?.connectionProperties = Connection.PROPERTY_SELF_MANAGED
}
connection?.connectionCapabilities = Connection.CAPABILITY_HOLD and Connection.CAPABILITY_SUPPORT_HOLD
connection?.setVideoState(VideoProfile.STATE_BIDIRECTIONAL)打电话:
val telecomService = context.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
try {
val uri = Uri.fromParts(PhoneAccount.SCHEME_SIP, teacherInfo.name, null)
telecomService.placeCall(uri, Bundle.EMPTY)
} catch (e: Throwable) {
e.printStackTrace()
}接听电话:
val telecomService = applicationContext.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
try {
Log.d("VideoCOnnection", "addNewIncomingCall")
telecomService.addNewIncomingCall(CallUtils.getAccountConnection(telecomService), Bundle.EMPTY)
} catch (e: Throwable) {
Log.d("VideoCOnnection", "crash")
e.printStackTrace()
}
@SuppressLint("MissingPermission")
fun getAccountConnection(teleconManager: TelecomManager) : PhoneAccountHandle? {
return if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val enabledAccounts = teleconManager.callCapablePhoneAccounts
for(account in enabledAccounts) {
if(account.componentName.className.equals(BindTelecomService::class.java.canonicalName)) {
return account
}
}
return null
} else
null
}发布于 2019-07-25 08:01:02
https://github.com/pranksterN1/TComTest https://stackoverflow.com/users/4466771/prankstern1发布了这个示例,但我仍然找不到,我的代码有什么问题:)附加服务,例如CallService示例只用于连接侦听,可以替换为GreenRobot的事件总线或Rx来简化
发布于 2019-04-30 09:23:02
看起来你想用自管理连接服务来实现这个应用程序。
检查您是否有权限:
在CAPABILITY_SELF_MANAGED上注册电话帐户。
final String phoneAccountLabel = "myPhoneApp";
ComponentName connectionServiceName = new ComponentName(context.getApplicationContext(), TcService.class);
accountHandle = new PhoneAccountHandle(connectionServiceName, phoneAccountLabel);
PhoneAccount phoneAccount = telecom.getPhoneAccount(accountHandle);
if (phoneAccount == null) {
PhoneAccount.Builder builder = PhoneAccount.builder(accountHandle, phoneAccountLabel);
builder.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED);
phoneAccount = builder.build();
telecom.registerPhoneAccount(phoneAccount);
}添加新的传入或传出电话时,必须添加额外的EXTRA_PHONE_ACCOUNT_HANDLE。
Uri uri = generateCallUri();
extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle);
telecom.addNewIncomingCall(accountHandle, extras);更新:有一个例子
https://stackoverflow.com/questions/53868446
复制相似问题