Android Multiple Notifications and with multiple intents

前端 未结 4 1037
攒了一身酷
攒了一身酷 2021-02-13 19:02

I have a fairly simple app that takes the input from a user and then sets it as a notification. The user can create as many notifications as he/she likes. I want the user to cli

4条回答
  •  生来不讨喜
    2021-02-13 19:40

    Use some random requestCode to seperate two notifications

    PendingIntent pendingIntent = PendingIntent.getActivity(context, CommonTools.getRandomNumber(1, 100),
                notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    
    public int getRandomNumber(int min, int max) {
        // min (inclusive) and max (exclusive)
        Random r = new Random();
        return r.nextInt(max - min) + min;
    }
    

提交回复
热议问题