我想編寫一個應用程序,發送兩種類型的通知。用戶應該看到他們兩個。來自一個應用程序的兩個並行通知(android)
直到現在,通知之間相互更新,即使我更改了pendingIntents的標誌。
即我的代碼:
Calendar calendar = Calendar.getInstance();
Intent intent = new Intent(this, Push.class);
Intent intent2 = new Intent(this, Push2.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent pendingIntent2 = PendingIntent.getBroadcast(this, 1, intent2, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
AlarmManager alarmManager2 = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis()+10, pendingIntent);
alarmManager2.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis()+10, pendingIntent2);
創建2個不同的通知構建器對象。 –
可能的重複http://stackoverflow.com/questions/18102052/how-to-display-multiple-notifications-in-android請檢查 –
你的問題是什麼? –