android.app.Notification
A class that represents how a persistent notification is to be presented to
the user using the NotificationManager.
Summary
Constants
|
|
|
Value |
|
Creator<Notification> |
CREATOR |
Parcelable.Creator that instantiates Notification objects
|
|
|
int |
DEFAULT_ALL |
Use all default values (where applicable). |
-1 |
0xffffffff |
int |
DEFAULT_LIGHTS |
Use the default notification lights. |
4 |
0x00000004 |
int |
DEFAULT_SOUND |
Use the default notification sound. |
1 |
0x00000001 |
int |
DEFAULT_VIBRATE |
Use the default notification vibrate. |
2 |
0x00000002 |
int |
FLAG_AUTO_CANCEL |
Bit to be bitwise-ored into the flags field that should be
set if the notification should be canceled when it is clicked by the
user. |
16 |
0x00000010 |
int |
FLAG_INSISTENT |
Bit to be bitwise-ored into the flags field that if set,
the audio and vibration will be repeated until the notification is
cancelled. |
4 |
0x00000004 |
int |
FLAG_NO_CLEAR |
Bit to be bitwise-ored into the flags field that should be
set if the notification should not be canceled when the user clicks
the Clear all button. |
32 |
0x00000020 |
int |
FLAG_ONGOING_EVENT |
Bit to be bitwise-ored into the flags field that should be
set if this notification is in reference to something that is ongoing,
like a phone call. |
2 |
0x00000002 |
int |
FLAG_ONLY_ALERT_ONCE |
Bit to be bitwise-ored into the flags field that should be
set if you want the sound and/or vibration play each time the
notification is sent, even if it has not been canceled before that. |
8 |
0x00000008 |
int |
FLAG_SHOW_LIGHTS |
Bit to be bitwise-ored into the flags field that should be
set if you want the LED on for this notification. |
1 |
0x00000001 |
int |
STREAM_DEFAULT |
Use this constant as the value for audioStreamType to request that
the default stream type for notifications be used. |
-1 |
0xffffffff |
Fields
public |
|
|
int |
audioStreamType |
The audio stream type to use when playing the sound. |
public |
|
|
PendingIntent |
contentIntent |
The intent to execute when the expanded status entry is clicked. |
public |
|
|
RemoteViews |
contentView |
The view that shows when this notification is shown in the expanded status bar. |
public |
|
|
int |
defaults |
Specifies which values should be taken from the defaults. |
public |
|
|
PendingIntent |
deleteIntent |
The intent to execute when the status entry is deleted by the user
with the "Clear All Notifications" button. |
public |
|
|
int |
flags |
|
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 |
|
|
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 |
|
|
int |
number |
The number of events that this notification represents. |
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
Public Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Constants
Parcelable.Creator that instantiates Notification objects
public
static
final
int
DEFAULT_ALL
Use all default values (where applicable).
Constant Value:
-1
(0xffffffff)
public
static
final
int
DEFAULT_LIGHTS
public
static
final
int
DEFAULT_SOUND
Use the default notification sound. This will ignore any given
sound.
Constant Value:
1
(0x00000001)
public
static
final
int
DEFAULT_VIBRATE
Use the default notification vibrate. This will ignore any given
vibrate.
Constant Value:
2
(0x00000002)
public
static
final
int
FLAG_AUTO_CANCEL
Bit to be bitwise-ored into the
flags field that should be
set if the notification should be canceled when it is clicked by the
user.
Constant Value:
16
(0x00000010)
public
static
final
int
FLAG_INSISTENT
Bit to be bitwise-ored into the
flags field that if set,
the audio and vibration will be repeated until the notification is
cancelled.
NOTE: This notion will change when we have decided exactly
what the UI will be.
Constant Value:
4
(0x00000004)
public
static
final
int
FLAG_NO_CLEAR
Bit to be bitwise-ored into the
flags field that should be
set if the notification should not be canceled when the user clicks
the Clear all button.
Constant Value:
32
(0x00000020)
public
static
final
int
FLAG_ONGOING_EVENT
Bit to be bitwise-ored into the
flags field that should be
set if this notification is in reference to something that is ongoing,
like a phone call. It should not be set if this notification is in
reference to something that happened at a particular point in time,
like a missed phone call.
Constant Value:
2
(0x00000002)
public
static
final
int
FLAG_ONLY_ALERT_ONCE
Bit to be bitwise-ored into the
flags field that should be
set if you want the sound and/or vibration play each time the
notification is sent, even if it has not been canceled before that.
Constant Value:
8
(0x00000008)
public
static
final
int
FLAG_SHOW_LIGHTS
Bit to be bitwise-ored into the
flags field that should be
set if you want the LED on for this notification.
- 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.
Constant Value:
1
(0x00000001)
public
static
final
int
STREAM_DEFAULT
Use this constant as the value for audioStreamType to request that
the default stream type for notifications be used. Currently the
default stream type is STREAM_RING.
Constant Value:
-1
(0xffffffff)
Fields
public
int
audioStreamType
The audio stream type to use when playing the sound.
Should be one of the STREAM_ constants from
AudioManager.
The intent to execute when the expanded status entry is clicked. If
this is an activity, it must include the
FLAG_ACTIVITY_NEW_TASK flag, which requires
that you take care of task management as described in the
application model document.
The view that shows when this notification is shown in the expanded status bar.
The intent to execute when the status entry is deleted by the user
with the "Clear All Notifications" button. This probably shouldn't
be launching an activity since several of those will be sent at the
same time.
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
int
ledARGB
The color of the led. The hardware will do its best approximation.
public
int
ledOffMS
The number of milliseconds for the LED to be off while it's flashing.
The hardware will do its best approximation.
public
int
ledOnMS
The number of milliseconds for the LED to be on while it's flashing.
The hardware will do its best approximation.
public
int
number
The number of events that this notification represents. For example, if this is the
new mail notification, this would be the number of unread messages. This number is
be superimposed over the icon in the status bar. If the number is 0 or negative, it
is not shown in the status bar.
public
Uri
sound
The sound to play.
To play the default notification sound, see defaults.
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 repeat if
FLAG_INSISTENT bit is set in the
flags field.
To vibrate the default pattern, see defaults.
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(int icon, CharSequence tickerText, long when)
Constructs a Notification object with the information needed to
have a status bar icon without the standard expanded view.
Parameters
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.
|
public
Notification(Parcel parcel)
Unflatten the notification from a parcel.
Public Methods
public
int
describeContents()
Describe the kinds of special objects contained in this Parcelable's
marshalled representation.
Sets the
contentView field to be a view with the standard "Latest Event"
layout.
Uses the icon and when fields to set the icon and time fields
in the view.
Parameters
context
| The context for your application / activity. |
contentTitle
| The title that goes in the expanded entry. |
contentText
| The text that goes in the expanded entry. |
contentIntent
| The intent to launch when the user clicks the expanded notification.
If this is an activity, it must include the
FLAG_ACTIVITY_NEW_TASK flag, which requires
that you take care of task management as described in the
application model document.
|
public
String
toString()
Returns a string containing a concise, human-readable description of the
receiver.
Returns
- String a printable representation for the receiver.
public
void
writeToParcel(Parcel parcel, int flags)
Flatten this notification from a parcel.