The Android 3.0 platform includes the Notification.Builder class that assists with the creation of user notification.
Notification.Builder builder = new Notification.Builder(NotificationBuilderDemo.this)
.setSmallIcon(R.drawable.icon_noti)
.setAutoCancel(true)
.setTicker(“Hello Bonga!”)
.setContentText(“La La La BONGA”)
.setContentIntent(intent);
NotificationManager manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
manager.notify(text.hashCode(), builder.getNotification());
The Notification.Builder class introduces a clear implementation for the Builder design pattern.
The Android 3.0 Tablets UI course I have recently completed to develop includes detailed slides that explain how do we use this class. The community version of this course is available for free personal usage at www.abelski.com.
The following video clip presents a simple demo for using this class. The source code is available for free personal usage in my Android 3.0 Tablet UI community course.