嗨我是新來的android和我正在開發提醒,有三個類別的第一個是設置多個約會提醒和第二個多月(票據)提醒,第三個多個每日(醫藥)提醒都在同一個項目中。android多個通知
所有的工作正常,但我有一個問題,當我設置三個提醒,他們都出現在LogCat上,所有時間都會觸發,但問題是當醫藥通知出現在酒吧通知和帳單提醒後, ,該賬單通知將取代滑下通知中的現有藥物提醒,反之亦然。約會提醒通知工作正常。
我需要通知所有三個類別的下滑通知,而不是用另一個替換現有的。
所以我認爲問題是在通知的代碼,但我無法弄清楚我的代碼中有什麼問題。
我對每個類別都有單獨的提醒服務。有人可以看看它,並告訴我什麼問題是?
這是服藥服務
public class Medicines_ReminderService extends WakeReminderIntentService {
public Medicines_ReminderService() {
super("ReminderService");
}
@Override
void doReminderWork(Intent intent) {
Log.d("MedicinesReminderService", "Doing work.");
Long rowId = intent.getExtras().getLong(RemindersDbAdapter.KEY_ROWID_MEDS);
NotificationManager mgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(this, MedicinesEdit.class);
notificationIntent.putExtra(RemindersDbAdapter.KEY_ROWID_MEDS, rowId);
int N_Med_requestCode = rowId.intValue();
PendingIntent pi = PendingIntent.getActivity(this, N_Med_requestCode, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
Notification note=new Notification(android.R.drawable.stat_sys_warning, getString(R.string.notify_new_reminder_message), System.currentTimeMillis());
note.setLatestEventInfo(this, getString(R.string.notify_new_medicine_reminder_title), getString(R.string.notify_new_reminder_message), pi);
note.defaults |= Notification.DEFAULT_SOUND;
note.flags |= Notification.FLAG_AUTO_CANCEL;
int id = (int)((long)rowId);
mgr.notify(id, note);
}
}
這是該法案提醒服務
public class Bills_ReminderService extends WakeReminderIntentService {
public Bills_ReminderService() {
super("ReminderService");
}
@Override
void doReminderWork(Intent intent) {
Log.d("BillsReminderService", "Doing work.");
Long rowId = intent.getExtras().getLong(RemindersDbAdapter.KEY_ROWID_BILLS);
NotificationManager mgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(this, BillsEdit.class);
notificationIntent.putExtra(RemindersDbAdapter.KEY_ROWID_BILLS, rowId);
int N_Bill_requestCode = rowId.intValue();
PendingIntent pi = PendingIntent.getActivity(this, N_Bill_requestCode, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
Notification note=new Notification(android.R.drawable.stat_sys_warning, getString(R.string.notify_new_reminder_message), System.currentTimeMillis());
note.setLatestEventInfo(this, getString(R.string.notify_new_bill_reminder_title), getString(R.string.notify_new_reminder_message), pi);
note.defaults |= Notification.DEFAULT_SOUND;
note.flags |= Notification.FLAG_AUTO_CANCEL;
int id = (int)((long)rowId);
mgr.notify(id, note);
}
}
在此先感謝
最好的問候, zoza