mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
fix: Properly stop foreground service
This commit is contained in:
parent
3e41030315
commit
8dcefc59eb
@ -37,7 +37,6 @@ class AudioRecorderModel: ViewModel() {
|
||||
val progress: Float
|
||||
get() = (recordingTime!! / recorderService!!.settings!!.maxDuration).toFloat()
|
||||
|
||||
private var intent: Intent? = null
|
||||
var recorderService: AudioRecorderService? = null
|
||||
private set
|
||||
|
||||
@ -86,15 +85,13 @@ class AudioRecorderModel: ViewModel() {
|
||||
}
|
||||
|
||||
fun startRecording(context: Context) {
|
||||
reset()
|
||||
|
||||
runCatching {
|
||||
context.unbindService(connection)
|
||||
}
|
||||
|
||||
intent = Intent(context, AudioRecorderService::class.java)
|
||||
ContextCompat.startForegroundService(context, intent!!)
|
||||
context.bindService(intent!!, connection, Context.BIND_AUTO_CREATE)
|
||||
val intent = Intent(context, AudioRecorderService::class.java)
|
||||
ContextCompat.startForegroundService(context, intent)
|
||||
context.bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||
}
|
||||
|
||||
fun stopRecording(context: Context, saveAsLastRecording: Boolean = true) {
|
||||
@ -104,9 +101,11 @@ class AudioRecorderModel: ViewModel() {
|
||||
|
||||
runCatching {
|
||||
context.unbindService(connection)
|
||||
context.stopService(intent)
|
||||
}
|
||||
|
||||
val intent = Intent(context, AudioRecorderService::class.java)
|
||||
context.stopService(intent)
|
||||
|
||||
reset()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user