fix: Unbind from service on dispose

This commit is contained in:
Myzel394 2023-08-17 11:33:59 +02:00
parent bf405aa76d
commit 191986a99f
No known key found for this signature in database
GPG Key ID: 50098FCA22080F0F

View File

@ -8,6 +8,7 @@ import androidx.compose.animation.scaleOut
import androidx.compose.foundation.background
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@ -41,7 +42,13 @@ fun Navigation(
.collectAsState(initial = null)
.value ?: return
audioRecorder.BindToService(context)
DisposableEffect(Unit) {
audioRecorder.bindToService(context)
onDispose {
audioRecorder.unbindFromService(context)
}
}
NavHost(
modifier = Modifier