通过我们的自定义协议使用telecomManager [英] Using telecomManager with our custom protocol

查看:411
本文介绍了通过我们的自定义协议使用telecomManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过以下指南实现与电信服务的互连: https: //developer.android.com/guide/topics/connectivity/telecom/

I`m trying to implement interconnection with telecom service with this guide: https://developer.android.com/guide/topics/connectivity/telecom/

我已经可以在没有电信服务的情况下显示自己的全屏来电UI,拨打和接听视频电话.我要使用Telecomservice做的所有事情,只是告诉Android OS,我们的应用程序正在特定时刻开始/停止视频通话,并接收来自其他正在调用的应用程序的通话保留/未保留事件.

I'm are already can show my own fullscreen incoming call UI without Telecom service, make and receive video calls. All, that I want to do with Telecomservice, is just tell Android OS, that our application is starting/stopping video call in particular moment, and receive call holded/unholded events from other calling apps.

主要问题是:

1)如果有传入呼叫,则addNewIncomingCall不会执行任何操作:不会触发onCreateIncomingConnection回调(甚至根本不会触发我的ConnectionService的onCreate回调).为什么未启动连接服务?

1) addNewIncomingCall in case of incoming call does nothing: onCreateIncomingConnection callback not fired (even onCreate callback of mine ConnectionService not fired at all). Why connection service is not started?

2)在拨出电话的情况下placeCall尝试使用我们的用户ID打开系统调用应用程序,将其作为电话或SIP号码进行调用.我可以在没有系统界面的情况下使用placeCall吗?

2) in case of outgoing call placeCall tries to open system calling app with our user id, call it as phone or SIP number. Can I use placeCall without system UI?

或者,如果我只想告知系统有关视频通话的信息​​,可以使用TelecomService以外的其他选项吗?

Or, if I just want to inform system about video call, I can use other option than 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
}

推荐答案

https://github.com/pranksterN1 /TComTest https://stackoverflow.com/users/4466771/prankstern1 发布了此示例,该示例有效,但我仍然找不到,我的代码出了什么问题:) 其他服务(例如example中的CallService)仅用于连接侦听,并且可以用GreenRobot的eventbus或Rx代替以简化操作

https://github.com/pranksterN1/TComTest https://stackoverflow.com/users/4466771/prankstern1 posted this example, which worked, but I still can not find, what's wrong with my code:) Additional Services, such as CallService from example is used for connection listening only, and can be replaced with GreenRobot's eventbus or Rx for simplification

这篇关于通过我们的自定义协议使用telecomManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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