Aniket
Aniket

Reputation: 1

I have implemented the code to raise local reminder notification everyday at specific time. On Android 14 phone not able to receive this notification

Below is my code snippet.

AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        android.icu.util.Calendar calendar = android.icu.util.Calendar.getInstance();
        android.icu.util.Calendar now = android.icu.util.Calendar.getInstance();
        calendar.set(android.icu.util.Calendar.HOUR_OF_DAY, hh);
        calendar.set(android.icu.util.Calendar.MINUTE, mm);
        calendar.set(android.icu.util.Calendar.SECOND, ss);
        //check whether the time is earlier than current time. If so, set it to tomorrow. Otherwise, all alarms for earlier time will fire
        if(calendar.before(now)){
            calendar.add(android.icu.util.Calendar.DATE, 1);
        }
        Intent alarmIntent = new Intent(NewDashboard.this, MedicineReminderReceiver.class);
        alarmIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        alarmIntent.putExtra("from","notification");
        alarmIntent.putExtra("ID",ID);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), ID, alarmIntent, PendingIntent.FLAG_IMMUTABLE);
        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
        editor.putBoolean(Constants.Preferences.SET_ALARM,true);
        editor.apply();

What change should be made in order to receive the notification of the Android 14

Upvotes: 0

Views: 34

Answers (0)

Related Questions