Commit 8f2aafeb authored by wanglei's avatar wanglei

...前台服务

parent 94bae9ec
......@@ -30,12 +30,12 @@ class StayJobService : JobService() {
companion object {
private val TAG = "StayJobService"
val NOTIFICATION_PERMANENT_ID = 186
val NOTIFICATION_STAY_ID = 186
private var isRunning = false
private const val JOB_INFO_ID: Int = 101
private const val JOB_PERIODIC: Long = 5 * 1000L
fun Context.startJob() {
if (isRunning) return
LogEx.logDebug(TAG, "startJob")
......@@ -59,12 +59,12 @@ class StayJobService : JobService() {
val notification = createPermanentNotification(applicationContext)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground(
NOTIFICATION_PERMANENT_ID,
NOTIFICATION_STAY_ID,
notification,
ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION
)
} else {
startForeground(NOTIFICATION_PERMANENT_ID, notification)
startForeground(NOTIFICATION_STAY_ID, notification)
}
isRunning = true
}
......@@ -74,7 +74,7 @@ class StayJobService : JobService() {
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.notify(
NOTIFICATION_PERMANENT_ID,
NOTIFICATION_STAY_ID,
createPermanentNotification(applicationContext)
)
}
......
......@@ -13,7 +13,7 @@ import android.widget.RemoteViews
import androidx.core.app.NotificationCompat
import androidx.core.graphics.drawable.IconCompat
import com.base.appzxhy.R
import com.base.appzxhy.service.StayJobService.Companion.NOTIFICATION_PERMANENT_ID
import com.base.appzxhy.service.StayJobService.Companion.NOTIFICATION_STAY_ID
import com.base.appzxhy.ui.main.MainActivity
object StayNotification {
......@@ -85,7 +85,7 @@ object StayNotification {
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.notify(
NOTIFICATION_PERMANENT_ID,
NOTIFICATION_STAY_ID,
createPermanentNotification(context)
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment