【问题标题】:How to set Local Notification for Everyday at 11:00 [duplicate]如何在 11:00 设置每天的本地通知 [重复]
【发布时间】:2017-02-08 09:26:25
【问题描述】:

我想在我的 android 应用程序中设置本地通知,每天上午 11:00 会来这里是我的代码..

    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);

这里没有显示任何通知..

如果我正在使用..

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

每次打开 Avtivity 时都会收到通知。

如果还有其他显示本地通知的方式,请举一些很好的例子。

【问题讨论】:

  • 如果AlarmBroadcastReceiverBroadcastReceiver,则必须使用getBroadcast()。此外,如果警报立即响起,则意味着您已将其设置为已经过去的时间。您需要检查一下,如果是,请添加一天。 stackoverflow.com/a/36536228 顺便说一句,14:45 不是上午 11 点。
  • Mike M 感谢您的帮助,我的问题已经解决了。

标签: android alarmmanager android-broadcastreceiver


【解决方案1】:

要检查的是通知的优先级。Ex in Custom OS.i.e LE eco 和 MIUI etc.Test in a stock OS mobile

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多