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
945b46ca
Commit
945b46ca
authored
Dec 30, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...闹钟
parent
fed75f19
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
6 deletions
+87
-6
MyApplication.kt
app/src/main/java/com/base/appzxhy/MyApplication.kt
+10
-5
AlarmReceiver.kt
...src/main/java/com/base/appzxhy/fcm/alarm/AlarmReceiver.kt
+39
-0
AlarmUtils.kt
app/src/main/java/com/base/appzxhy/fcm/alarm/AlarmUtils.kt
+37
-0
TimerManager.kt
app/src/main/java/com/base/appzxhy/fcm/timer/TimerManager.kt
+1
-1
No files found.
app/src/main/java/com/base/appzxhy/MyApplication.kt
View file @
945b46ca
package
com.base.appzxhy
import
AlarmUtils.startAlarm
import
android.app.Activity
import
android.app.Application
import
android.content.Context
...
...
@@ -13,13 +14,14 @@ import com.base.appzxhy.bean.config.AdConfigBean
import
com.base.appzxhy.bean.config.ConfigBean
import
com.base.appzxhy.bean.config.PopupConfigBean
import
com.base.appzxhy.fcm.FCMManager
import
com.base.appzxhy.fcm.TimerManager.Companion.changeTimer
import
com.base.appzxhy.fcm.
timer.
TimerManager.Companion.changeTimer
import
com.base.appzxhy.fcm.receiver.BatteryStatusReceiver
import
com.base.appzxhy.fcm.receiver.PackageStatusReceiver
import
com.base.appzxhy.fcm.receiver.ScreenStatusReceiver
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.helper.InstallHelps
import
com.base.appzxhy.helper.NewComUtils
import
com.base.appzxhy.service.StayJobService.Companion.startJob
import
com.base.appzxhy.ui.start.StartActivity
import
com.base.appzxhy.utils.ActivityManagerUtils
import
com.base.appzxhy.utils.AppPreferences
...
...
@@ -135,10 +137,13 @@ class MyApplication : Application() {
PackageStatusReceiver
.
registerPackageStatusReceiver
(
this
)
BatteryStatusReceiver
.
registerBatteryStatusReceiver
(
this
)
// startJob()
// startAlarm(appContext, 24)
// startAlarm(appContext, 48)
// startAlarm(appContext, 72)
startAlarm
(
appContext
,
24
)
startAlarm
(
appContext
,
48
)
startAlarm
(
appContext
,
72
)
kotlin
.
runCatching
{
startJob
()
}
}
...
...
app/src/main/java/com/base/appzxhy/fcm/alarm/AlarmReceiver.kt
0 → 100644
View file @
945b46ca
package
com.base.appzxhy.fcm.alarm
import
android.annotation.SuppressLint
import
android.content.BroadcastReceiver
import
android.content.Context
import
android.content.Intent
import
com.base.appzxhy.bean.NotificationSendBean
import
com.base.appzxhy.bean.NotificationSendBean.Companion.POPUP_WHERE_ALARM
import
com.base.appzxhy.fcm.notification.MyNotificationManager
import
com.base.appzxhy.fcm.work.RepeatingWorker.Companion.schedulePeriodicWork
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.utils.AppPreferences
import
com.base.appzxhy.utils.LogEx
/**
*
*/
class
AlarmReceiver
:
BroadcastReceiver
()
{
private
val
TAG
=
"AlarmJobReceiver"
@SuppressLint
(
"UnsafeProtectedBroadcastReceiver"
)
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
?)
{
LogEx
.
logDebug
(
TAG
,
"AlarmJobReceiver onReceive"
)
val
lastAlarmTime
=
AppPreferences
.
getInstance
().
getLong
(
"lastAlarmTime"
,
0L
)
val
currentTime
=
System
.
currentTimeMillis
()
if
(
lastAlarmTime
==
0L
||
currentTime
-
lastAlarmTime
>=
1000
*
30
*
60
)
{
EventUtils
.
event
(
"alarm_push"
)
val
sendBean
=
NotificationSendBean
(
context
,
POPUP_WHERE_ALARM
,
canSend
=
{
true
},
sendSuccess
=
{})
MyNotificationManager
.
submitSendBean
(
sendBean
)
AppPreferences
.
getInstance
().
put
(
"lastAlarmTime"
,
System
.
currentTimeMillis
())
}
schedulePeriodicWork
(
context
)
return
}
}
\ No newline at end of file
app/src/main/java/com/base/appzxhy/fcm/alarm/AlarmUtils.kt
0 → 100644
View file @
945b46ca
import
android.app.AlarmManager
import
android.app.PendingIntent
import
android.app.job.JobService
import
android.content.Context
import
android.content.Intent
import
com.base.appzxhy.BuildConfig
import
com.base.appzxhy.fcm.alarm.AlarmReceiver
import
com.base.appzxhy.fcm.work.RepeatingWorker.Companion.schedulePeriodicWork
import
java.util.Calendar
object
AlarmUtils
{
fun
startAlarm
(
context
:
Context
,
hour
:
Int
)
{
// context.startJob()
//闹钟定时任务
val
alarmManager
=
context
.
getSystemService
(
JobService
.
ALARM_SERVICE
)
as
AlarmManager
val
pendingIntent
=
PendingIntent
.
getBroadcast
(
context
,
hour
,
Intent
(
context
,
AlarmReceiver
::
class
.
java
),
PendingIntent
.
FLAG_IMMUTABLE
or
PendingIntent
.
FLAG_UPDATE_CURRENT
)
val
calendar
=
Calendar
.
getInstance
()
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
6
)
calendar
.
set
(
Calendar
.
MINUTE
,
0
)
calendar
.
set
(
Calendar
.
SECOND
,
0
)
val
oneHour
=
60
*
60
*
1000L
var
delay
=
oneHour
*
hour
if
(
BuildConfig
.
DEBUG
)
{
delay
=
1
*
60
*
1000L
}
alarmManager
.
setRepeating
(
AlarmManager
.
RTC_WAKEUP
,
calendar
.
timeInMillis
,
delay
,
pendingIntent
)
schedulePeriodicWork
(
context
)
}
}
\ No newline at end of file
app/src/main/java/com/base/appzxhy/fcm/TimerManager.kt
→
app/src/main/java/com/base/appzxhy/fcm/
timer/
TimerManager.kt
View file @
945b46ca
package
com.base.appzxhy.fcm
package
com.base.appzxhy.fcm
.timer
import
com.base.appzxhy.MyApplication
import
com.base.appzxhy.bean.config.PopupConfigBean.Companion.popupConfigBean
...
...
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