Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
A
appzxhy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhouzhi
appzxhy
Commits
8f2aafeb
Commit
8f2aafeb
authored
Dec 27, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...前台服务
parent
94bae9ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
StayJobService.kt
app/src/main/java/com/base/appzxhy/service/StayJobService.kt
+5
-5
StayNotification.kt
...rc/main/java/com/base/appzxhy/service/StayNotification.kt
+2
-2
No files found.
app/src/main/java/com/base/appzxhy/service/StayJobService.kt
View file @
8f2aafeb
...
...
@@ -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
)
)
}
...
...
app/src/main/java/com/base/appzxhy/service/StayNotification.kt
View file @
8f2aafeb
...
...
@@ -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
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment