English | Site Directory

Android - An Open Handset Alliance Project

android.app
public class

android.app.Notification

java.lang.Object
android.app.Notification Parcelable

A class that represents how a persistent notification is to be presented to the user using the NotificationManager.

Summary

Constants

      Value  
Creator  CREATOR  Parcelable.Creator that instantiates Notification objects      

Fields

public      Intent  appIntent  The intent to execute when the app icon is clicked. 
public      Intent  contentIntent  The intent to execute when the expanded status entry is clicked. 
public      RemoteViews  expandedView  The view that shows when this notification is shown in the expanded status bar. 
public      int  icon  The resource id of a drawable to use as the icon in the status bar. 
public      int  iconLevel  If the icon in the status bar is to have more than one level, you can set this. 
public      boolean  insistent  If true, audio and vibration will be repeated until the notification is cancelled. 
public      int  ledARGB  The color of the led. 
public      int  ledOffMS  The number of milliseconds for the LED to be off while it's flashing. 
public      int  ledOnMS  The number of milliseconds for the LED to be on while it's flashing. 
public      boolean  lights  Set to true if you want the LED on for this notification. Set to false otherwise.  
public      boolean  ongoingEvent  True if this notification is in reference to something that is ongoing, like a phone call. 
public      Uri  sound  The sound to play. 
public      CharSequence  tickerText  Text to scroll across the screen when this item is added to the status bar. 
public      long[]  vibrate  The pattern with which to vibrate. 
public      long  when  The timestamp for the notification. 

Public Constructors

          Notification()
Constructs a Notification object with everything set to 0.
          Notification(Context context, int icon, CharSequence tickerText, long when, CharSequence expandedTitle, CharSequence expandedText, Intent contentIntent, int appIcon, CharSequence appName, Intent appIntent)
Constructs a Notification object with the information needed to have a status bar icon and the standard expanded view.
          Notification(Parcel parcel)
Unflatten the notification from a parcel.

Public Methods

        void  writeToParcel(Parcel parcel)
Flatten this notification from a parcel.
Methods inherited from class java.lang.Object
Methods inherited from interface android.os.Parcelable

Details

Constants

public static final Creator CREATOR

Parcelable.Creator that instantiates Notification objects

Fields

public Intent appIntent

The intent to execute when the app icon is clicked.

public Intent contentIntent

The intent to execute when the expanded status entry is clicked.

public RemoteViews expandedView

The view that shows when this notification is shown in the expanded status bar.

public int icon

The resource id of a drawable to use as the icon in the status bar.

public int iconLevel

If the icon in the status bar is to have more than one level, you can set this. Otherwise, leave it at its default value of 0.

public boolean insistent

If true, audio and vibration will be repeated until the notification is cancelled.

NOTE: This notion will change when we have decided excatly what the UI will be.

public int ledARGB

The color of the led. The hardware will do its best approximation.

See Also

public int ledOffMS

The number of milliseconds for the LED to be off while it's flashing. The hardware will do its best approximation.

See Also

public int ledOnMS

The number of milliseconds for the LED to be on while it's flashing. The hardware will do its best approximation.

See Also

public boolean lights

Set to true if you want the LED on for this notification. Set to false otherwise.

  • To turn the LED off, pass 0 in the alpha channel for colorARGB or 0 for both ledOnMS and ledOffMS.
  • To turn the LED on, pass 1 for ledOnMS and 0 for ledOffMS.
  • To flash the LED, pass the number of milliseconds that it should be on and off to ledOnMS and ledOffMS.

Since hardware varies, you are not guaranteed that any of the values you pass are honored exactly. Use the system defaults (TODO) if possible because they will be set to values that work on any given hardware.

The alpha channel must be set for forward compatibility.

public boolean ongoingEvent

True if this notification is in reference to something that is ongoing, like a phone call. False if this notification is in reference to something that happened at a particular point in time, like a missed phone call.

public Uri sound

The sound to play.

public CharSequence tickerText

Text to scroll across the screen when this item is added to the status bar.

public long[] vibrate

The pattern with which to vibrate. This pattern will repeate if insistent is true.

public long when

The timestamp for the notification. The icons and expanded views are sorted by this key.

Public Constructors

public Notification()

Constructs a Notification object with everything set to 0.

public Notification(Context context, int icon, CharSequence tickerText, long when, CharSequence expandedTitle, CharSequence expandedText, Intent contentIntent, int appIcon, CharSequence appName, Intent appIntent)

Constructs a Notification object with the information needed to have a status bar icon and the standard expanded view.

Parameters

context The context for your application / activity.
icon The resource id of the icon to put in the status bar.
tickerText The text that flows by in the status bar when the notification first activates.
when The time to show in the time field. In the System.currentTimeMillis timebase.
expandedTitle The title that goes in the expanded entry.
expandedText The text that goes in the expanded entry.
contentIntent The intent to launch when the user clicks the expanded notification.
appIcon The icon to show for the application.
appName The name of the application.
appIntent The intent to launch when the user clicks the application icon.

public Notification(Parcel parcel)

Unflatten the notification from a parcel.

Public Methods

public void writeToParcel(Parcel parcel)

Flatten this notification from a parcel.
Build m5-rc15i - 10 Jun 2008 13:54