NotifyWithTextpublic class NotifyWithText extends android.app.Activity When you push the button on this Activity, it schedules a notification
using the notifyWithText method. |
Methods Summary |
---|
protected void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
setContentView(R.layout.notify_with_text);
Button button;
// short notification
button = (Button) findViewById(R.id.short_notify);
button.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
// Get the notification manager serivce.
NotificationManager nm = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
// The id we use here happens to be the id of the text we
// display. You can use any int here that is unique within
// your application.
nm.notifyWithText(R.id.short_notify,
getText(R.string.short_notification_text),
NotificationManager.LENGTH_SHORT, null);
}
});
// long notification
// The only difference here is that the notification stays up longer.
// You might want to use this if there is more text that they're going
// to read, like an email subject or something.
button = (Button) findViewById(R.id.long_notify);
button.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
NotificationManager nm = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
nm.notifyWithText(R.id.long_notify,
getText(R.string.long_notification_text),
NotificationManager.LENGTH_LONG, null);
}
});
|
|