How to display multiple notifications in android

前端 未结 18 1357
既然无缘
既然无缘 2020-11-29 19:39

I am receiving only one notification and if there comes another notification, it replaces the previous one and here is my code

private static void generateNo         


        
18条回答
  •  温柔的废话
    2020-11-29 20:09

    Using Shared Preferences worked for me

    SharedPreferences prefs = getSharedPreferences(Activity.class.getSimpleName(), Context.MODE_PRIVATE);
    int notificationNumber = prefs.getInt("notificationNumber", 0);
    ...
    
    notificationManager.notify(notificationNumber , notification);
    SharedPreferences.Editor editor = prefs.edit();
    notificationNumber++;
    editor.putInt("notificationNumber", notificationNumber);
    editor.commit();
    

提交回复
热议问题