fix: Unbind from service on dispose

This commit is contained in:
Myzel394 2023-08-17 11:30:32 +02:00
parent d87c7a182e
commit fead95f1fc
No known key found for this signature in database
GPG Key ID: 50098FCA22080F0F

View File

@ -120,12 +120,15 @@ class AudioRecorderModel: ViewModel() {
recorderService?.amplitudesAmount = amount
}
@Composable
fun BindToService(context: Context) {
LaunchedEffect(Unit) {
Intent(context, AudioRecorderService::class.java).also { intent ->
context.bindService(intent, connection, 0)
}
fun bindToService(context: Context) {
Intent(context, AudioRecorderService::class.java).also { intent ->
context.bindService(intent, connection, 0)
}
}
fun unbindFromService(context: Context) {
runCatching {
context.unbindService(connection)
}
}
}