Search code examples
androidalarmmanagerandroid-broadcastreceiver

How to set Local Notification for Everyday at 11:00


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.


Solution

  • 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