mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-22 05:38:55 +00:00
Alarm usage for SDK >= M use setAndAllowWhiteIdle to handle batch alarms
This commit is contained in:
parent
525870745a
commit
749d698fc3
1 changed files with 5 additions and 5 deletions
|
|
@ -13,7 +13,6 @@ import com.habitrpg.android.habitica.models.tasks.RemindersItem
|
|||
import com.habitrpg.android.habitica.models.tasks.Task
|
||||
import com.habitrpg.android.habitica.receivers.NotificationPublisher
|
||||
import com.habitrpg.android.habitica.receivers.TaskReceiver
|
||||
import com.habitrpg.common.habitica.helpers.ExceptionHandler
|
||||
import com.habitrpg.shared.habitica.HLogger
|
||||
import com.habitrpg.shared.habitica.LogLevel
|
||||
import com.habitrpg.shared.habitica.models.tasks.TaskType
|
||||
|
|
@ -220,11 +219,10 @@ class TaskAlarmManager(
|
|||
return
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
alarmManager?.setWindow(AlarmManager.RTC_WAKEUP, time, 60000, pendingIntent)
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
//For SDK >= Android 12, allows batching of reminders
|
||||
try {
|
||||
alarmManager?.setAlarmClock(AlarmClockInfo(time, pendingIntent), pendingIntent)
|
||||
alarmManager?.setAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, time, pendingIntent)
|
||||
} catch (ex: Exception) {
|
||||
when (ex) {
|
||||
is IllegalStateException, is SecurityException -> {
|
||||
|
|
@ -233,6 +231,8 @@ class TaskAlarmManager(
|
|||
else -> throw ex
|
||||
}
|
||||
}
|
||||
} else {
|
||||
alarmManager?.setWindow(AlarmManager.RTC_WAKEUP, time, 60000, pendingIntent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue