如何使用OpenTok收听来自应用程序的来电视频



当视频呼叫使用OpenTok SDK进入我的应用程序时,我需要显示呼叫接受/拒绝屏幕。我还应该在我的应用程序关闭时接听来电。我能做些什么来从应用程序收听视频通话。他们是任何监听方式,当我拒绝或跳过呼叫时,它将在我的呼叫历史记录中显示为未接来电。提前感谢:(

创建视频呼叫来VideoCallComingActivity活动

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创建YourJobIntentService扩展

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接收关于即将到来的视频呼叫的通知:

override fun onMessageReceived(remoteMessage: RemoteMessage?) {
super.onMessageReceived(remoteMessage)
// More code here
YourJobIntentService.enqueueWork(applicationContext, intent)
}

当我拒绝或跳过呼叫时,它将在我的呼叫历史记录中显示为未接来电->我认为这取决于您的应用程序逻辑。

最新更新