Try to suppress crashes because of startForegroundService
Sometimes, this method is called before the app is in foreground resulting in crash because of A12 foreground limitations, so we try to catch the exception
This commit is contained in:
parent
8cd3fcfd38
commit
8b5b6d0e64
1 changed files with 4 additions and 2 deletions
|
@ -132,7 +132,9 @@ object MusicPlayerRemote : KoinComponent {
|
|||
try {
|
||||
contextWrapper.startService(intent)
|
||||
} catch (ignored: IllegalStateException) {
|
||||
ContextCompat.startForegroundService(context, intent)
|
||||
runCatching {
|
||||
ContextCompat.startForegroundService(context, intent)
|
||||
}
|
||||
}
|
||||
val binder = ServiceBinder(callback)
|
||||
|
||||
|
@ -260,7 +262,7 @@ object MusicPlayerRemote : KoinComponent {
|
|||
private fun tryToHandleOpenPlayingQueue(
|
||||
queue: List<Song>,
|
||||
startPosition: Int,
|
||||
startPlaying: Boolean
|
||||
startPlaying: Boolean,
|
||||
): Boolean {
|
||||
if (playingQueue === queue) {
|
||||
if (startPlaying) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue