kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
use ServiceCompat.stopForeground() for API < 24 compatibility
rodzic
af05355186
commit
b8ee4152a3
|
@ -5,6 +5,7 @@ import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.os.RemoteException
|
import android.os.RemoteException
|
||||||
|
import androidx.core.app.ServiceCompat
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import com.geeksville.mesh.analytics.DataPair
|
import com.geeksville.mesh.analytics.DataPair
|
||||||
import com.geeksville.mesh.android.GeeksvilleApplication
|
import com.geeksville.mesh.android.GeeksvilleApplication
|
||||||
|
@ -263,7 +264,7 @@ class MeshService : Service(), Logging {
|
||||||
|
|
||||||
startForeground(serviceNotifications.notifyId, notification)
|
startForeground(serviceNotifications.notifyId, notification)
|
||||||
return if (!wantForeground) {
|
return if (!wantForeground) {
|
||||||
stopForeground(STOP_FOREGROUND_REMOVE)
|
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)
|
||||||
START_NOT_STICKY
|
START_NOT_STICKY
|
||||||
} else {
|
} else {
|
||||||
START_STICKY
|
START_STICKY
|
||||||
|
@ -275,7 +276,8 @@ class MeshService : Service(), Logging {
|
||||||
|
|
||||||
saveSettings()
|
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()
|
serviceNotifications.close()
|
||||||
|
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
|
|
Ładowanie…
Reference in New Issue