1

I need to set alarm for the user to remind them to take a medication. the alarm triggering on sometime and not.

Once application get rebooted, On Boot receiver, I'm reseting alarm once again. Even though it's not triggering.

     AlarmManager manager = AlarmManagerProvider.getAlarmManager(context);
    int uniqueId = CommonUtils.generateRandomID();
    Intent intent = new Intent(context, PrescriptionAlarmActivity.class);
    Cursor cursor = null;
    if (reminderTask != null) {
        cursor = context.getContentResolver().query(reminderTask, null, null, null, null);
    }
    String description = "";
    try {
        if (cursor != null && cursor.moveToFirst()) {
            description = AlarmReminderContract.getColumnString(cursor, AlarmReminderContract.AlarmReminderEntry.KEY_TITLE);

        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    intent.putExtra("medicineName", description);
    PendingIntent operation = PendingIntent.getActivity(context, uniqueId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    //manager.setRepeating(AlarmManager.RTC_WAKEUP, alarmTime, RepeatTime, operation);

    try {
        manager.setInexactRepeating(AlarmManager.RTC_WAKEUP, alarmTime, RepeatTime,
                operation);
    } catch (Exception e) {
        e.printStackTrace();
    }

for 1st day, alarm triggers and the next day it's not working.

androider
  • 105
  • 1
  • 9
  • You can use WorkManager and set PeriodicWorkRequest, here some good article about it https://medium.com/androiddevelopers/workmanager-periodicity-ff35185ff006 – MrVasilev Sep 24 '19 at 11:54

0 Answers0