2011-12-04 13 views
2

こんにちは私はアンドロイドが新しく、最初の1つは複数のアポイントメントリマインダーを設定し、2つ目は複数の月々の(請求書)リマインダを設定することです。毎日(薬)のリマインダーはすべて同じプロジェクトにあります。android multiple notification

LogCatに表示される3つのアラームを時間通りに設定すると問題はありますが、バー通知に薬の通知が表示され、その後に請求通知が発生するこの請求書通知は、スライドダウン通知の既存の薬通知を置き換え、逆も同様である。予定リマインダ通知が正常に機能しています。

スライドダウン通知の3つのカテゴリのすべてについて、既存のものを別のものに置き換えずに通知する必要があります。

私はこの問題が通知のコードにあると思いますが、私のコードで何が問題であるか把握できませんでした。

私はそれぞれのカテゴリー別にリマインダーサービスを別にしています。誰かがそれを見て、問題が何であるか教えてくれますか?

これは、薬のリマインダーサービス

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

答えて

4

法案リマインダーサービスですそれがプロであるときの「一意の」識別子としての行IDあなたが持っている3つのサービスの間に独特のものではありません。

すなわちhttp://developer.android.com/guide/topics/ui/notifiers/notifications.html

のドキュメントから

int id = (int)((long)rowId); 
    mgr.notify(id, note); 

はあなたの通知を管理する「IDが一意にあなたのアプリケーション内からの通知を識別します。あなたは、通知を更新する必要がある場合やIDが必要です(アプリケーションがさまざまな種類の通知を管理している場合)、ユーザーが通知に定義されているインテントでアプリケーションに戻るときに、適切なアクションを選択します。

あなただけが使用することができ、カテゴリごとに1つの通知が必要な場合:

int BillsID=1; 
    int MedsID=2; 

    mgr.notify(BillsID, note); 
    mgr.notify(MedsID, note); 

またはあなたが本当にあなたが同じことを避けるために差別を追加する必要があり、その行数に基づいて、各通知を必要としない場合IDは別々の通知に割り当てられます。

int BillsID=100000; 
    int MedsID=200000; 
    mgr.notify(BillsID+RowID, note); 
    mgr.notify(MedsID+RowID, note);