gpt4 book ai didi

java - 如何使用 OpenTok 收听来 self 的应用程序的传入视频通话?

转载 作者:行者123 更新时间:2023-12-01 21:58:13 26 4
gpt4 key购买 nike

当使用 OpenTok SDK 在我的应用程序中进行视频通话时,我需要显示通话接受/拒绝屏幕。当我的应用程序被终止时,我还应该监听来电。我可以做什么来收听应用程序中的视频通话。他们可以通过任何方式收听,当我拒绝或跳过调用时,它将在我的通话记录中显示为未接来电。提前致谢:)

最佳答案

创建视频通话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 Activity 。使用 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)
}

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

关于java - 如何使用 OpenTok 收听来 self 的应用程序的传入视频通话?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58723440/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com