How can i listen a incoming video call from my app using OpenTok?

前端 未结 1 490
执笔经年
执笔经年 2021-01-23 17:54

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 list

相关标签:
1条回答
  • 2021-01-23 18:25

    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
                )
            } 
    }
    

    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)
            }
        }
    }
    

    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.

    0 讨论(0)
提交回复
热议问题