【发布时间】:2011-01-17 05:44:25
【问题描述】:
您好,我一直在研究 android 中的警报管理器,想知道是否有如何设置警报的特定时间(或可以使用通知管理器)在特定时间(例如明天下午 12 点)响起。 下面的代码从现在开始将警报设置为 5 秒,因此将其设置为下午 12 点,您可以执行 12:00:00 之类的操作吗?
Intent intent = new Intent(this, OnetimeAlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, REQUEST_CODE, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (5 * 1000), sender);
Toast.makeText(this, "Alarm set", Toast.LENGTH_LONG).show();
【问题讨论】: