【发布时间】:2012-12-06 10:42:16
【问题描述】:
我从 webserivce 获取日期和时间形式的数据,这意味着对于某些特定日期,我有一些插槽。下图给出了详细的解释。
在每个日期,我都有一些时间安排。这里我想要的是在特定日期和时间显示通知。如果来自数据库的响应包含明天的日期,例如 2012 年 7 月 12 日上午 11:00。我需要在那个时候显示通知。
我对通知管理器和我正在使用的代码有一些想法。
Main.java
NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_action_search, "A New Message!", System.currentTimeMillis());
Intent notificationIntent = new Intent(this, Main.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(Main.this, notificationTitle, notificationMessage, pendingIntent);
notificationManager.notify(10001, notification);
但是在这里我还需要在应用关闭时收到通知。所以,任何人都可以帮我解决这个问题。
【问题讨论】:
-
你可以编写服务来完成这个任务:-vogella.com/articles/AndroidServices/article.html
标签: android notifications android-notifications