/*
* Here we send a notification that is both transient and persistent.
* The transient part is the view that comes up and shows the user
* the text of what could be an incoming message. The persistent part
* goes into the status bar where they can acknowledge it later.
*/
// look up the notification manager service
NotificationManager nm = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
// the transient notification =======================================
// create the view
View view = inflateView(R.layout.incoming_message_panel);
// set the text in the view
TextView tv = (TextView)view.findViewById(R.id.message);
tv.setText("kthx. meet u for dinner. cul8r");
// the persistent notification ======================================
// what happens when we click the icon
Intent clickIntent = new Intent(Intent.MAIN_ACTION);
clickIntent.setClass(this, IncomingMessageView.class);
// construct the Notification object.
Notification notif = new Notification(
R.drawable.stat_sample,
getText(R.string.status_bar_notification_title),
clickIntent, null, null);
// after a 100ms delay, vibrate for 250ms, pause for 100 ms and
// then vibrate for 500ms.
notif.vibrate = new long[] { 100, 250, 100, 500};
// send the notification ============================================
nm.notifyWithView(R.layout.incoming_message_panel, view,
NotificationManager.LENGTH_LONG, notif);