We want to send many notifications on to status bar.
Create function like this.
public void noti(int number,String title, String message) {
NotificationCompat.Builder b = new
NotificationCompat.Builder(this);
b.setAutoCancel(true)
.setDefaults(NotificationCompat.DEFAULT_ALL)
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ic_launcher)
.setTicker("{your tiny message}")
.setContentTitle(title)
.setContentText(message)
.setContentInfo("INFO");
NotificationManager nm = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(number, b.build());
}
Call function like this.
noti(1338,
"Title", "Content");
To send another message.
noti(1339, "Title 2",
"Another content");
No comments:
Post a Comment