Skip to content

Commit

Permalink
Fixed sNotz reminder in higher Android versions
Browse files Browse the repository at this point in the history
Signed-off-by: sunilpaulmathew <[email protected]>
  • Loading branch information
sunilpaulmathew committed Sep 15, 2024
1 parent bf92926 commit 55685e7
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;

import androidx.appcompat.widget.AppCompatImageButton;

Expand Down Expand Up @@ -115,7 +117,17 @@ private static void setReminder(AppCompatImageButton button, boolean modify, dou
}

mIntent.putExtra("id", mNotificationID);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && !mAlarmManager.canScheduleExactAlarms()) {
Intent intent = new Intent(Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM);
intent.setData(Uri.parse("package:" + context.getPackageName()));
context.startActivity(intent);
return;
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !mAlarmManager.canScheduleExactAlarms()) {
Intent intent = new Intent(Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM);
context.startActivity(intent);
return;
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
mAlarmManager.setExact(AlarmManager.RTC_WAKEUP, mCalendar.getTimeInMillis(), mPendingIntent);
} else {
mAlarmManager.set(AlarmManager.RTC_WAKEUP, mCalendar.getTimeInMillis(), mPendingIntent);
Expand Down

0 comments on commit 55685e7

Please sign in to comment.