2013-03-18 1 views
0

약을 먹을 때마다 내 앱이 상태 표시 줄에 알림을 표시해야합니다. 두 개의 약을 동시에 복용해야한다면 두 통의 통보가 나타납니다. 현재 알약 시간이 다른 경우 내 앱에서 별도의 알림을 표시 할 수 있습니다. 문제는 그들이 동시에 (버튼을 누를 때) 가장 최근에 생성 된 것만 표시한다는 것입니다. 그러나 그것은 여전히 ​​두 번 진동합니다. 어떤 제안?두 개의 개별 알림을 동시에 표시하는 방법은 무엇입니까?

정보 클래스 :

DatabaseHelper notiDb = new DatabaseHelper(this); 
    notiDb.open(); 
    final String dataName = notiDb.getDataName(pushed_name); 
    String dataDaily = notiDb.getDataDaily(pushed_name); 
    final String dataWeekly = notiDb.getDataWeekly(pushed_name); 
    String dataTwice = notiDb.getDataTwice(pushed_name); 
    final String dataDosage = notiDb.getDataDosage(pushed_name); 
    String dataStart = notiDb.getDataStart(pushed_name); 
    String dataID = notiDb.getDataID(pushed_name); 
    notiDb.close(); 

    ID = Integer.parseInt(dataID); 
    int value_Weekly = Integer.parseInt(dataWeekly); 
    int value_Daily = Integer.parseInt(dataDaily); 
    int value_Twice = Integer.parseInt(dataTwice); 
    int value_Start = Integer.parseInt(dataStart); 

    Calendar calendar = Calendar.getInstance(); 
    calendar.set(Calendar.HOUR_OF_DAY, value_Start); 
    calendar.set(Calendar.MINUTE, 00); 
    calendar.set(Calendar.SECOND, 00); 
    int setTime = (value_Daily*value_Twice)/value_Weekly; 



    Intent intent_noti = new Intent(this,Alarm.class); 
    intent_noti.putExtra("ID", ID); 
    intent_noti.setData(Uri.parse(intent_noti.toUri(Intent.URI_INTENT_SCHEME))); 
    PendingIntent pendingIntent = PendingIntent.getActivity(this, ID, intent_noti, PendingIntent.FLAG_ONE_SHOT); 
    AlarmManager am = (AlarmManager)getSystemService(Activity.ALARM_SERVICE); 
    am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), setTime, pendingIntent); 

경보 등급 :

DatabaseHelper notiDb = new DatabaseHelper(this); 
    notiDb.open(); 
    final String dataName = notiDb.getDataName(pushed_name); 
    String dataDaily = notiDb.getDataDaily(pushed_name); 
    String dataWeekly = notiDb.getDataWeekly(pushed_name); 
    String dataTwice = notiDb.getDataTwice(pushed_name); 
    String dataDosage = notiDb.getDataDosage(pushed_name); 
    String dataStart = notiDb.getDataStart(pushed_name); 
    String dataID = notiDb.getDataID(pushed_name); 
    notiDb.close(); 

    ID = Integer.parseInt(dataID); 


    Intent intent_unique = new Intent(this, NotiScenario.class); 
    intent_unique.putExtra("ID", ID); 
    intent_unique.setData(Uri.parse(intent_unique.toUri(Intent.URI_INTENT_SCHEME))); 
    PendingIntent pIntent = PendingIntent.getActivity(this, ID, intent_unique, 0); 


    // Build notification 
    Notification noti = new Notification.Builder(this) 
     .setContentTitle("MedScan") 
     .setContentText("3. You should take "+dataDosage +" pills of " +dataName) 
     .setSmallIcon(R.drawable.original) 
     .setContentIntent(pIntent) 
     .build(); 
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 

    noti.defaults |= Notification.DEFAULT_ALL; 
    //Hide the notification after its selected 
    noti.flags |= Notification.FLAG_AUTO_CANCEL; 

    notificationManager.notify(ID, noti); 

답변

1

같은 통지의 ID인가? 그게 사실이라면 그 통보를 무시하는 것 같아요. 서로 여러 알림을 표시하려면 다른 ID를 사용하십시오.

+0

ID는 고유하지 않습니다. 그들이 다르다는 것을 확인하기 위해 검사했습니다. 환약 중 하나가 "1"인 반면 다른 환약은 "2" – anaconda122

관련 문제