Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: what is the id of startForeground(id,notification) in Service Class

What is the id parameter in startForground method in Service class.I found that answer by googling for single Notification.How do the guy find the id ? any list or reference for this.What if i want to show multiple notification like facebook. How do i define the id then ?

notification.flags = Notification.FLAG_NO_CLEAR;
startForeground(1337, notification);
like image 338
Ovi Avatar asked Aug 11 '16 08:08

Ovi


1 Answers

Simple notification_id needs to be changeable.

Just create random number for notification_id.

    Random random = new Random();
    int m = random.nextInt(9999 - 1000) + 1000;
or
        int m = System.currentTimeMillis()%10000;

and replace this line to add parameter for notification id as to generate random number

    startForeground(m, notification);
like image 146
Godslave Avatar answered Oct 22 '22 18:10

Godslave