Android Multiple Notification

后端 未结 2 1674
我在风中等你
我在风中等你 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. :)

提交回复
热议问题