Android Multiple Notification

后端 未结 2 1673
我在风中等你
我在风中等你 2021-01-05 09:24

I have developing an App where the user can create event and set notification for that very event. So I want to add multiple notification. I am using the following code.

相关标签:
2条回答
  • 2021-01-05 09:39

    Below is the code for pass unique notification id:

    //"CommonUtilities.getValudeFromOreference" is the method created by me to get value from savedPreferences.
    String notificationId = CommonUtilities.getValueFromPreference(context, Global.NOTIFICATION_ID, "0");
    int notificationIdinInt = Integer.parseInt(notificationId);
    
    notificationManager.notify(notificationIdinInt, notification);
    
    // will increment notification id for uniqueness
    notificationIdinInt = notificationIdinInt + 1;
    CommonUtilities.saveValueToPreference(context, Global.NOTIFICATION_ID, notificationIdinInt + "");
    //Above "CommonUtilities.saveValueToPreference" is the method created by me to save new value in savePreferences.
    

    Let me know if you need more detail information or any query. :)

    0 讨论(0)
  • 2021-01-05 09:55

    I assume that SIMPLE_NOTIFICATION_ID is a constant? To have separate notifications you need to use a different ID for each one.

    0 讨论(0)
提交回复
热议问题