我可以在指定时间之前15分钟触发警报吗?

时间:2019-05-30 07:07:27

标签: android

 time = (calendar.getTimeInMillis() -(calendar.getTimeInMillis()%60000));
    if(System.currentTimeMillis()>time)
    {
        if (calendar.AM == 1)
        {time = time + (1000*60*60*12);
            System.out.println(time);}
        else
            time = time + (1000*60*60*24);
    }
    Intent intent = new Intent(MainActivity.this, AlarmReceiver.class);
    PendingIntent pendingIntent = 
           PendingIntent.getBroadcast(MainActivity.this, 0, intent, 0);
    alarmManager.setExact(AlarmManager.RTC_WAKEUP, 
                                       time-(15*60*1000),pendingIntent);

我可以在警报集之前15分钟触发警报吗,就像我在代码(alarmManager.setExact())中提到的那样?如果我将警报设置为00:00(Hour_of_day),则必须在23:45(前一天)。

0 个答案:

没有答案