mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-06 03:18:23 +00:00
Merge pull request #337 from greenart7c3/claude/fix-foreground-service-notification-o4HNa
Update foreground service to use ServiceCompat for Android 14+ compatibility
This commit is contained in:
@@ -2,11 +2,14 @@ package com.greenart7c3.nostrsigner.service
|
||||
|
||||
import android.app.Service
|
||||
import android.content.Intent
|
||||
import android.content.pm.ServiceInfo
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Network
|
||||
import android.net.NetworkCapabilities
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import android.util.Log
|
||||
import androidx.core.app.ServiceCompat
|
||||
import com.greenart7c3.nostrsigner.Amber
|
||||
import com.greenart7c3.nostrsigner.BuildFlavorChecker
|
||||
import com.greenart7c3.nostrsigner.LocalPreferences
|
||||
@@ -169,7 +172,18 @@ class ConnectivityService : Service() {
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
Log.d(Amber.TAG, "onStartCommand")
|
||||
startForeground(1, Amber.instance.stats.createForegroundNotification())
|
||||
val foregroundServiceType =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
|
||||
} else {
|
||||
0
|
||||
}
|
||||
ServiceCompat.startForeground(
|
||||
this,
|
||||
1,
|
||||
Amber.instance.stats.createForegroundNotification(),
|
||||
foregroundServiceType,
|
||||
)
|
||||
return START_STICKY
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user