mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2024-12-15 17:58:33 +01:00
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="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>
|
||||||
|
@ -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
Block a user