Add SCHEDULE_EXACT_ALARM permission

This commit is contained in:
jacques 2023-01-09 17:22:48 +01:00
parent 87fd45cfa1
commit 1a93cd3fd6
2 changed files with 7 additions and 6 deletions

View file

@ -5,7 +5,10 @@
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>
<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.SCHEDULE_EXACT_ALARM"/>
<application <application
android:fullBackupContent="true" android:fullBackupContent="true"

View file

@ -42,6 +42,7 @@ public class AlarmReceiver extends BroadcastReceiver {
calendar.setTimeInMillis(nextSchedule.getTime()); calendar.setTimeInMillis(nextSchedule.getTime());
} else { } else {
calendar.set(Calendar.HOUR_OF_DAY, 11); calendar.set(Calendar.HOUR_OF_DAY, 11);
calendar.set(Calendar.MINUTE, 15);
today = calendar.getTime(); today = calendar.getTime();
calendar.add(Calendar.DAY_OF_YEAR, 1); calendar.add(Calendar.DAY_OF_YEAR, 1);
tomorrow = calendar.getTime(); tomorrow = calendar.getTime();
@ -60,12 +61,9 @@ public class AlarmReceiver extends BroadcastReceiver {
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,(calendar.getTimeInMillis()), alarmManager.setExact(AlarmManager.RTC_WAKEUP, (calendar.getTimeInMillis()), alarmIntent);
AlarmManager.ELAPSED_REALTIME, alarmIntent);
} else { } else {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, (calendar.getTimeInMillis()), alarmIntent);
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, (calendar.getTimeInMillis()),
AlarmManager.INTERVAL_DAY, alarmIntent);
} }
Log.d(TAG, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis())); Log.d(TAG, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis()));
@ -149,8 +147,8 @@ public class AlarmReceiver extends BroadcastReceiver {
} }
private void createNotificationChannel(Context context) { private void createNotificationChannel(Context context) {
Log.d(TAG, "start create notification channel"); Log.d(TAG, "start create notification channel");
CharSequence name = context.getString(R.string.channel_name); CharSequence name = context.getString(R.string.channel_name);
String description = context.getString(R.string.channel_description); String description = context.getString(R.string.channel_description);
int importance = NotificationManager.IMPORTANCE_DEFAULT; int importance = NotificationManager.IMPORTANCE_DEFAULT;