【发布时间】:2011-09-24 17:43:44
【问题描述】:
我知道如何在某个点击事件后 X 毫秒开始通知。像这样的代码
Timer timer = new Timer();
TimerTask timerTask = new TimerTask() {
@Override
public void run() {
triggerNotification();
}
};
timer.schedule(timerTask, 3000);
通知代码如下所示
CharSequence title = "Hello";
CharSequence message = "Hello, Android!";
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon, "A New Message!", System.currentTimeMillis());
Intent notificationIntent = new Intent(this, AndroidAlarmService.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(AndroidAlarmService.this, title, message, pendingIntent);
notification.defaults = Notification.DEFAULT_SOUND;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(NOTIFICATION_ID, notification);
如何将通知设置为在特定日期的特定时间出现,比如 10 月 1 日晚上 7 点?
【问题讨论】:
标签: android notifications