FileDocCategorySizeDatePackage
NotifyWithText.javaAPI DocGoogle Android v1.5 Example2894Sun Nov 11 13:01:04 GMT 2007com.google.android.samples.app

NotifyWithText

public class NotifyWithText extends android.app.Activity
When you push the button on this Activity, it schedules a notification using the notifyWithText method.
see
NotificationManager#notifyWithText(int,CharSequence,int,Notification);
see
NotificationManager#LENGTH_SHORT
see
NotificationManager#LENGTH_LONG

Fields Summary
Constructors Summary
Methods Summary
protected voidonCreate(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);
            }
        });