A Toast Notification, for brief messages that come
from the background.
Basic
Positioning your Toast
Creating a Custom Toast View
A Status Bar Notification, for persistent reminders
that come from the background and request the user's response.
A Dialog Notification, for Activity-related notifications.
Notification on status bar
Common flags
PendingIntent.FLAG_UPDATE_CURRENT Update contents on status bar if the notification already exists, it is used when to invoke PendingIntent.getActivity, PendingIntent.getBroadcast, and PendingIntent.getService.
Notification.FLAG_AUTO_CANCEL Cancel the notification when it is clicked by user. It is bitwise-ored into the flags field of Notification.
Notification.FLAG_NO_CLEAR Prevent user to cancel it. It is bitwise-ored into the flags field of Notification.
xx
Notification
Don't show time on status bar Notificaton notification = xxx. notification.when = 0; //Must invoke before setLatestEventInfo ... //Other statements
xxx
NotificationManager
id The id of notification is application's own resource, that mean multiple applications can define the same id.
contentIntent this field must be set and it can't be null. If you don't want to trigger any intent when use click status bar, just use the following code snip: Intent intent = new Intent(); PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, intent, 0); notification.contentIntent = pi;