Bind to screen sharing service after app killed and relaunched.

This commit is contained in:
Onuray Sahin 2022-05-06 13:21:33 +03:00
parent b486559469
commit cf3d145cd6
2 changed files with 11 additions and 2 deletions

View File

@ -164,6 +164,9 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
}
}
}
// Bind to service in case of user killed the app while there is an ongoing call
bindToScreenCaptureService()
}
override fun onNewIntent(intent: Intent?) {
@ -662,9 +665,13 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
this,
Intent(this, ScreenCaptureService::class.java)
)
bindToScreenCaptureService(activityResult)
}
private fun bindToScreenCaptureService(activityResult: ActivityResult? = null) {
screenCaptureServiceConnection.bind(object : ScreenCaptureServiceConnection.Callback {
override fun onServiceConnected() {
startScreenSharing(activityResult)
activityResult?.let { startScreenSharing(it) }
}
})
}

View File

@ -38,7 +38,9 @@ class ScreenCaptureServiceConnection @Inject constructor(
fun bind(callback: Callback) {
this.callback = callback
if (!isBound) {
if (isBound) {
callback.onServiceConnected()
} else {
Intent(context, ScreenCaptureService::class.java).also { intent ->
context.bindService(intent, this, 0)
}