schedule enabled alarms on reboot
This commit is contained in:
parent
244a137e5b
commit
928177e8be
|
@ -5,6 +5,7 @@
|
|||
|
||||
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
|
@ -58,5 +59,13 @@
|
|||
<service android:name=".services.SnoozeService"/>
|
||||
|
||||
<receiver android:name=".receivers.AlarmReceiver"/>
|
||||
|
||||
<receiver android:name=".receivers.BootCompletedReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
|
||||
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.simplemobiletools.clock.receivers
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.simplemobiletools.clock.extensions.dbHelper
|
||||
import com.simplemobiletools.clock.extensions.scheduleNextAlarm
|
||||
|
||||
class BootCompletedReceiver : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
context.dbHelper.getAlarms().filter { it.isEnabled }.forEach {
|
||||
context.scheduleNextAlarm(it, false)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue