Создание видеовызова 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)
}
когда я отклоняю или пропускаю вызов, тогда онбудет отображаться в моей истории вызовов как пропущенный вызов -> Я думаю, это зависит от логики вашего приложения.