Java 我如何使用OpenTok收听来自我的应用程序的传入视频呼叫?
当使用OpenTok SDK在我的应用程序中进行视频通话时,我需要显示通话接受/拒绝屏幕。当我的应用程序被关闭时,我还应该监听来电。我可以从应用程序收听视频通话吗。他们可以通过任何方式收听,当我拒绝或跳过通话时,它将在我的通话记录中显示为未接来电。Java 我如何使用OpenTok收听来自我的应用程序的传入视频呼叫?,java,android,kotlin,Java,Android,Kotlin,当使用OpenTok SDK在我的应用程序中进行视频通话时,我需要显示通话接受/拒绝屏幕。当我的应用程序被关闭时,我还应该监听来电。我可以从应用程序收听视频通话吗。他们可以通过任何方式收听,当我拒绝或跳过通话时,它将在我的通话记录中显示为未接来电。 提前感谢:)创建视频通话来VideoCallComingActivityactivity override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(save
提前感谢:)创建视频通话来
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或更高版本的后台限制。创建YourJobIntentService
扩展自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接收视频通话通知:
override fun onMessageReceived(remoteMessage: RemoteMessage?) {
super.onMessageReceived(remoteMessage)
// More code here
YourJobIntentService.enqueueWork(applicationContext, intent)
}
当我拒绝或跳过呼叫时,它将在我的呼叫历史记录中显示为未接呼叫->我认为这取决于你的应用程序逻辑。创建视频呼叫来
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或更高版本的后台限制。创建YourJobIntentService
扩展自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接收视频通话通知:
override fun onMessageReceived(remoteMessage: RemoteMessage?) {
super.onMessageReceived(remoteMessage)
// More code here
YourJobIntentService.enqueueWork(applicationContext, intent)
}
当我拒绝或跳过呼叫时,它将在我的呼叫历史记录中显示为未接呼叫->我认为这取决于你的应用程序逻辑。John Le,谢谢你的回答。但是我还有一个例子,如果用户从设置中关闭通知,那么我该怎么听呢?因为在whatsapp上,我们可以在通知关闭时听。@DavinderGoel:AFAK关闭通知不会影响Firebase通知。您好,我在屏幕关闭时遇到这个错误,plz帮助``由以下原因引起:android.util.AndroidRuntimeException:Intent{act=android.Intent.action.MAIN flg=0x14008000 cmp=com.civix.link/.Screen.CallingScreen}`无法启动活动`` John Le,感谢您的回答。但是我还有一个例子,如果用户从设置中关闭通知,那么我该怎么听呢?因为在whatsapp上,我们可以在通知关闭时听。@DavinderGoel:AFAK关闭通知不会影响Firebase通知。您好,我在屏幕关闭时遇到这个错误,plz帮助``由以下原因引起:android.util.AndroidRuntimeException:无法为Intent启动活动{act=android.Intent.action.MAIN flg=0x14008000 cmp=com.civix.link/.Screen.CallingScreen}``你好@davinder你能解决这个问题吗?你好@davinder你能解决这个问题吗?