use ServiceCompat.stopForeground() for API < 24 compatibility

pull/566/head
andrekir 2023-01-03 21:02:31 -03:00
rodzic af05355186
commit b8ee4152a3
1 zmienionych plików z 4 dodań i 2 usunięć

Wyświetl plik

@ -5,6 +5,7 @@ import android.content.Context
import android.content.Intent
import android.os.IBinder
import android.os.RemoteException
import androidx.core.app.ServiceCompat
import androidx.core.content.edit
import com.geeksville.mesh.analytics.DataPair
import com.geeksville.mesh.android.GeeksvilleApplication
@ -263,7 +264,7 @@ class MeshService : Service(), Logging {
startForeground(serviceNotifications.notifyId, notification)
return if (!wantForeground) {
stopForeground(STOP_FOREGROUND_REMOVE)
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)
START_NOT_STICKY
} else {
START_STICKY
@ -275,7 +276,8 @@ class MeshService : Service(), Logging {
saveSettings()
stopForeground(STOP_FOREGROUND_REMOVE) // Make sure we aren't using the notification first
// Make sure we aren't using the notification first
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)
serviceNotifications.close()
super.onDestroy()