Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to send multiply push-notifications and show number of them
    primarykey
    data
    text
    <p>I have a server with some data and in my app I want to show this data via push-notification, so the problem is I didn't get how to cooperate notification number in status bar with my notifiсations. In my app I get notifications as <code>ArrayList</code> from my server. For each notification I should use a "Notification builder", in which I'll put notify fields like icon, name, desc etc, and at least I should call "NotificationManager.notify" for each of them, but how I can show that I've just gotten 3 messages for example in my status bar(one icon with indicator of 3, NOT 3 icons), and don't multiply a notification sound, but still show all of them when I open a status bar. </p> <p><strong>My code</strong>:</p> <pre><code> public void sendNotifications(ArrayList&lt;Message&gt; messages){ int notifyID = 0; mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); for(Message message:messages){ Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(),0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); Resources res = getApplicationContext().getResources(); Notification.Builder builder = new Notification.Builder(getApplicationContext()); builder.setContentIntent(contentIntent) .setSmallIcon(R.drawable.ic_launcher) .setLargeIcon(BitmapFactory.decodeResource(res, messages.media)) .setTicker("Got a new message") .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setContentTitle(message.titile) .setContentText(message.text); Notification notification = builder.getNotification(); mNotificationManager.notify(notifyID, notification); notifyID++; } } </code></pre> <h1>UPD</h1> <p>For more understanding what i want to i've added an images</p> <p>-pic1 When i send notifications - icon shows me how much i got</p> <p><img src="https://i.stack.imgur.com/4MLnJ.jpg" alt="When i send notifications"></p> <p>-pic2 When i opened a status bar it shows me all my notifies</p> <p><img src="https://i.stack.imgur.com/rUnLI.jpg" alt="shows me my notifies"></p> <p>It is possible to do that?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload