如何使用OpenTok收听来自我的应用程序的视频通话? [英] How can i listen a incoming video call from my app using OpenTok?

查看:116
本文介绍了如何使用OpenTok收听来自我的应用程序的视频通话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用OpenTok SDK在我的应用程序中进行视频通话时,我需要显示通话接受/拒绝屏幕.我的应用程式被杀死时,我还应该收听来电.我可以做些什么来收听来自应用程序的视频通话.他们是任何收听方式,当我拒绝或跳过通话时,它将在我的通话记录中显示为未接来电. 在此先感谢:)

i need to show call accept/reject screen while a video call coming in my app using OpenTok SDK. I should also listen incoming call while my app is killed. What can i do for listen video call from app. their is any way to listen and when i reject or skip the call then it will show in my call history as missed call. Thanks in Advance:)

推荐答案

创建即将进行VideoCallComingActivity活动的视频通话

Create a video call coming VideoCallComingActivity activity

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // setContentView(you layout id)

        // Setup your activity which can open when the screen is clocked
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
            setShowWhenLocked(true)
            setTurnScreenOn(true)
            (getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager).requestDismissKeyguard(this, null)
        } else {
            window?.addFlags(
                    WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or
                            WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
                            WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
            )
        } 
}

使用JobIntentService服务启动VideoCallComingActivity活动.使用JobIntentService可以避免Android 8或更高版本的背景限制.从JobIntentService

Using JobIntentService service for starting the VideoCallComingActivity activity. Using JobIntentService to avoid the background restriction from Android 8 or higher. Create YourJobIntentService extends from JobIntentService

class YourJobIntentService : JobIntentService() {
    override fun onHandleWork(it: Intent) {
        // Start the VideoCallComingActivity activity
    }

    // OR static method in Java
    companion object {
        fun enqueueWork(context: Context, intent: Intent) {
            enqueueWork(context, YourJobIntentService::class.java, 1000, intent)
        }
    }
}

使用Firebase接收有关视频通话即将到来的通知:

Using Firebase to receiving notification about a video call coming:

    override fun onMessageReceived(remoteMessage: RemoteMessage?) {
        super.onMessageReceived(remoteMessage)

        // More code here
        YourJobIntentService.enqueueWork(applicationContext, intent)
    }

当我拒绝或跳过通话时,它将在我的通话记录中显示为未接来电->我认为这取决于您的应用逻辑.

when i reject or skip the call then it will show in my call history as missed call -> I think it depends on your app logic.

这篇关于如何使用OpenTok收听来自我的应用程序的视频通话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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