Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在给定的日期/时间重复报警?_Java_Android_Broadcastreceiver_Alarmmanager - Fatal编程技术网

Java 如何在给定的日期/时间重复报警?

Java 如何在给定的日期/时间重复报警?,java,android,broadcastreceiver,alarmmanager,Java,Android,Broadcastreceiver,Alarmmanager,使用广播接收器,如何使alarmmanager重复给定的日期/天/时间 public void startAlert(String time, String title) { long timeInMillis = Long.decode(time); intent = new Intent(this, AlarmReceiver.class); intent.putExtra("myTitle", title); alarmmanager = (AlarmMan

使用广播接收器,如何使alarmmanager重复给定的日期/天/时间

public void startAlert(String time, String title) {
    long timeInMillis = Long.decode(time);
    intent = new Intent(this, AlarmReceiver.class);
    intent.putExtra("myTitle", title);
    alarmmanager = (AlarmManager) getSystemService(ALARM_SERVICE);
    pendingIntent = PendingIntent.getBroadcast(this, (int) Long.parseLong(time), intent, PendingIntent.FLAG_UPDATE_CURRENT);
    alarmmanager.set(AlarmManager.RTC_WAKEUP, timeInMillis, pendingIntent);
}

使用
setRepeating
代替
set

下面是正确的语法-

alarmmanager.setRepeating(AlarmManager.RTC_WAKEUP,
        startUpTime, AlarmManager.INTERVAL_DAY, pendingIntent);

我想你可以用setRepeating来定制这样的日期

alarmmanager.setRepeating(alarmmanager.RTC_唤醒, 启动时间、AlarmManager.INTERVAL_DAY、PendingEvent)


我知道命令,但我下一步怎么办?我如何告诉它在任何一天都能工作?不是每天,不是每个星期天,而是用户选择的任何一天。在这种情况下,您必须像用户选择的任何一天一样开发逻辑,您必须计算从现在到那天的间隔,并使用该间隔,希望它能有所帮助,否则我将不得不编写完整的代码并向您展示。