【发布时间】:2011-02-03 15:28:43
【问题描述】:
我正在尝试在我的笔记/待办事项应用程序中使用提醒/警报服务`。我可以为特定项目设置提醒,警报触发并成功显示通知。
我的问题是我的Service 怎么知道哪个笔记/待办事项设置了那个特定的提醒。我希望用户能够单击状态栏中的通知并让触发它的项目出现。但我无法将该信息传递给Service,因为他们不接受来自PendingIntent 的Bundles。
我目前使用以下设置闹钟:
private void createAlarm() {
Intent i = new Intent(this, AlarmService.class);
PendingIntent sender = PendingIntent.getService(this, 0, i, 0);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, mReminderCal.getTimeInMillis(), sender);
}
我只需要一种方法在我的数据库中发送项目的_id,这样我的服务就可以在单击通知时使用相同的_id 启动项目。
我希望我的问题不会太混乱。
谢谢!
【问题讨论】:
标签: android service alarmmanager android-pendingintent