0

I want to set local notification in my android app which will come everyday at 11:00 AM everyday here is my code..

    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 14);
    calendar.set(Calendar.MINUTE, 45);
    calendar.set(Calendar.SECOND, 0);

    Intent intent1 = new Intent(this, AlarmBroadcastReceiver.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 1234, intent1, PendingIntent.FLAG_UPDATE_CURRENT);
    AlarmManager am = (AlarmManager) this.getSystemService(this.ALARM_SERVICE);
    am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);

Here Its not showing any notification..

If Iam using..

PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 1234, intent1, PendingIntent.FLAG_UPDATE_CURRENT);

Than notification comes everytime I open my Avtivity.

And If any other way to show local notification please give some good examples.

Amit Upadhyay
  • 7,179
  • 4
  • 43
  • 57
Sandeep Mishra
  • 650
  • 2
  • 9
  • 20
  • 1
    If `AlarmBroadcastReceiver` is a `BroadcastReceiver`, you have to use `getBroadcast()`. Also, if the alarm fires immediately, it means you've set it for a time that's already passed. You need to check that, and add a day if so. http://stackoverflow.com/a/36536228 Btw, 14:45 is not 11am. – Mike M. Feb 08 '17 at 09:29
  • 1
    Mike M thanks for ur help, my problem was solved. – Sandeep Mishra Feb 08 '17 at 12:07

1 Answers1

1

Thing to check is the priority of notifications.Ex in Custom OS.i.e LE eco and MIUI etc.Test in a stock OS mobile

Hitesh Danidhariya
  • 709
  • 1
  • 7
  • 14