schedule enabled alarms on reboot

This commit is contained in:
tibbi 2018-03-07 15:48:09 +01:00
parent 244a137e5b
commit 928177e8be
2 changed files with 25 additions and 0 deletions

View File

@ -5,6 +5,7 @@
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/> <uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
<uses-permission android:name="android.permission.VIBRATE"/> <uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application <application
android:name=".App" android:name=".App"
@ -58,5 +59,13 @@
<service android:name=".services.SnoozeService"/> <service android:name=".services.SnoozeService"/>
<receiver android:name=".receivers.AlarmReceiver"/> <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> </application>
</manifest> </manifest>

View File

@ -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)
}
}
}