Tag: 移动应用程序

Android Notification在应用程序启动时触发

我正在尝试让我的每日通知服务正常工作,但我遇到了问题。 我应该只在将来的某个特定时间收到通知,但我注意到了 if (time_that_i_set_for_notification < current_time_of_the_day) notification triggers at the boot of my app 这是错误的,因为在这种情况下,通知应该仅在第二天触发,而不是在我启动应用程序的瞬间。 这是我试图让事情奏效的尝试: 我在我的MainActivity,onCreate()方法中调用它 : private void scheduleNotification(int hour, int minute){ Intent notificationIntent = new Intent(this, NotificationReceiver.class); notificationIntent.putExtra(“notifId”, notifId); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, notifId, notificationIntent, 0); // Set the alarm to start at approximately at a time DatePicker datePicker = new DatePicker(this); […]