ctor public Notification(android.os.Parcel);
method public android.app.Notification clone();
method public int describeContents();
+ method public int getBadgeIcon();
method public java.lang.String getChannel();
method public java.lang.String getGroup();
method public android.graphics.drawable.Icon getLargeIcon();
+ method public java.lang.String getShortcutId();
method public android.graphics.drawable.Icon getSmallIcon();
method public java.lang.String getSortKey();
method public long getTimeout();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.media.AudioAttributes AUDIO_ATTRIBUTES_DEFAULT;
+ field public static final int BADGE_ICON_LARGE = 2; // 0x2
+ field public static final int BADGE_ICON_NONE = 0; // 0x0
+ field public static final int BADGE_ICON_SMALL = 1; // 0x1
field public static final java.lang.String CATEGORY_ALARM = "alarm";
field public static final java.lang.String CATEGORY_CALL = "call";
field public static final java.lang.String CATEGORY_EMAIL = "email";
field public deprecated int ledARGB;
field public deprecated int ledOffMS;
field public deprecated int ledOnMS;
- field public deprecated int number;
+ field public int number;
field public deprecated int priority;
field public android.app.Notification publicVersion;
field public deprecated android.net.Uri sound;
method public android.app.Notification.Builder addExtras(android.os.Bundle);
method public android.app.Notification.Builder addPerson(java.lang.String);
method public android.app.Notification build();
+ method public android.app.Notification.Builder chooseBadgeIcon(int);
method public android.widget.RemoteViews createBigContentView();
method public android.widget.RemoteViews createContentView();
method public android.widget.RemoteViews createHeadsUpContentView();
method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon);
method public deprecated android.app.Notification.Builder setLights(int, int, int);
method public android.app.Notification.Builder setLocalOnly(boolean);
- method public deprecated android.app.Notification.Builder setNumber(int);
+ method public android.app.Notification.Builder setNumber(int);
method public android.app.Notification.Builder setOngoing(boolean);
method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
method public deprecated android.app.Notification.Builder setPriority(int);
method public android.app.Notification.Builder setProgress(int, int, boolean);
method public android.app.Notification.Builder setPublicVersion(android.app.Notification);
method public android.app.Notification.Builder setRemoteInputHistory(java.lang.CharSequence[]);
+ method public android.app.Notification.Builder setShortcutId(java.lang.String);
method public android.app.Notification.Builder setShowWhen(boolean);
method public android.app.Notification.Builder setSmallIcon(int);
method public android.app.Notification.Builder setSmallIcon(int, int);
ctor public Notification(android.os.Parcel);
method public android.app.Notification clone();
method public int describeContents();
+ method public int getBadgeIcon();
method public java.lang.String getChannel();
method public java.lang.String getGroup();
method public android.graphics.drawable.Icon getLargeIcon();
method public static java.lang.Class<? extends android.app.Notification.Style> getNotificationStyleClass(java.lang.String);
+ method public java.lang.String getShortcutId();
method public android.graphics.drawable.Icon getSmallIcon();
method public java.lang.String getSortKey();
method public long getTimeout();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.media.AudioAttributes AUDIO_ATTRIBUTES_DEFAULT;
+ field public static final int BADGE_ICON_LARGE = 2; // 0x2
+ field public static final int BADGE_ICON_NONE = 0; // 0x0
+ field public static final int BADGE_ICON_SMALL = 1; // 0x1
field public static final java.lang.String CATEGORY_ALARM = "alarm";
field public static final java.lang.String CATEGORY_CALL = "call";
field public static final java.lang.String CATEGORY_EMAIL = "email";
field public deprecated int ledARGB;
field public deprecated int ledOffMS;
field public deprecated int ledOnMS;
- field public deprecated int number;
+ field public int number;
field public deprecated int priority;
field public android.app.Notification publicVersion;
field public deprecated android.net.Uri sound;
method public android.app.Notification.Builder addExtras(android.os.Bundle);
method public android.app.Notification.Builder addPerson(java.lang.String);
method public android.app.Notification build();
+ method public android.app.Notification.Builder chooseBadgeIcon(int);
method public android.widget.RemoteViews createBigContentView();
method public android.widget.RemoteViews createContentView();
method public android.widget.RemoteViews createHeadsUpContentView();
method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon);
method public deprecated android.app.Notification.Builder setLights(int, int, int);
method public android.app.Notification.Builder setLocalOnly(boolean);
- method public deprecated android.app.Notification.Builder setNumber(int);
+ method public android.app.Notification.Builder setNumber(int);
method public android.app.Notification.Builder setOngoing(boolean);
method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
method public deprecated android.app.Notification.Builder setPriority(int);
method public android.app.Notification.Builder setProgress(int, int, boolean);
method public android.app.Notification.Builder setPublicVersion(android.app.Notification);
method public android.app.Notification.Builder setRemoteInputHistory(java.lang.CharSequence[]);
+ method public android.app.Notification.Builder setShortcutId(java.lang.String);
method public android.app.Notification.Builder setShowWhen(boolean);
method public android.app.Notification.Builder setSmallIcon(int);
method public android.app.Notification.Builder setSmallIcon(int, int);
ctor public Notification(android.os.Parcel);
method public android.app.Notification clone();
method public int describeContents();
+ method public int getBadgeIcon();
method public java.lang.String getChannel();
method public java.lang.String getGroup();
method public android.graphics.drawable.Icon getLargeIcon();
+ method public java.lang.String getShortcutId();
method public android.graphics.drawable.Icon getSmallIcon();
method public java.lang.String getSortKey();
method public long getTimeout();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.media.AudioAttributes AUDIO_ATTRIBUTES_DEFAULT;
+ field public static final int BADGE_ICON_LARGE = 2; // 0x2
+ field public static final int BADGE_ICON_NONE = 0; // 0x0
+ field public static final int BADGE_ICON_SMALL = 1; // 0x1
field public static final java.lang.String CATEGORY_ALARM = "alarm";
field public static final java.lang.String CATEGORY_CALL = "call";
field public static final java.lang.String CATEGORY_EMAIL = "email";
field public deprecated int ledARGB;
field public deprecated int ledOffMS;
field public deprecated int ledOnMS;
- field public deprecated int number;
+ field public int number;
field public deprecated int priority;
field public android.app.Notification publicVersion;
field public deprecated android.net.Uri sound;
method public android.app.Notification.Builder addExtras(android.os.Bundle);
method public android.app.Notification.Builder addPerson(java.lang.String);
method public android.app.Notification build();
+ method public android.app.Notification.Builder chooseBadgeIcon(int);
method public android.widget.RemoteViews createBigContentView();
method public android.widget.RemoteViews createContentView();
method public android.widget.RemoteViews createHeadsUpContentView();
method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon);
method public deprecated android.app.Notification.Builder setLights(int, int, int);
method public android.app.Notification.Builder setLocalOnly(boolean);
- method public deprecated android.app.Notification.Builder setNumber(int);
+ method public android.app.Notification.Builder setNumber(int);
method public android.app.Notification.Builder setOngoing(boolean);
method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
method public deprecated android.app.Notification.Builder setPriority(int);
method public android.app.Notification.Builder setProgress(int, int, boolean);
method public android.app.Notification.Builder setPublicVersion(android.app.Notification);
method public android.app.Notification.Builder setRemoteInputHistory(java.lang.CharSequence[]);
+ method public android.app.Notification.Builder setShortcutId(java.lang.String);
method public android.app.Notification.Builder setShowWhen(boolean);
method public android.app.Notification.Builder setSmallIcon(int);
method public android.app.Notification.Builder setSmallIcon(int, int);
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.ShortcutInfo;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.Canvas;
* superimposed over the icon in the status bar. Starting with
* {@link android.os.Build.VERSION_CODES#HONEYCOMB}, the template used by
* {@link Notification.Builder} has displayed the number in the expanded notification view.
+ * Starting with {@link android.os.Build.VERSION_CODES#O}, the number may be displayed as a
+ * badge icon in Launchers that support badging.
*
- * If the number is 0 or negative, it is never shown.
- *
- * @deprecated this number is not shown anymore
*/
- @Deprecated
- public int number;
+ public int number = 1;
/**
* The intent to execute when the expanded status entry is clicked. If
private String mChannelId;
private long mTimeout;
+ private String mShortcutId;
+
+ /**
+ * If this notification is being shown as a badge, always show as a number.
+ */
+ public static final int BADGE_ICON_NONE = 0;
+
+ /**
+ * If this notification is being shown as a badge, use the {@link #getSmallIcon()} to
+ * represent this notification.
+ */
+ public static final int BADGE_ICON_SMALL = 1;
+
+ /**
+ * If this notification is being shown as a badge, use the {@link #getLargeIcon()} to
+ * represent this notification.
+ */
+ public static final int BADGE_ICON_LARGE = 2;
+ private int mBadgeIcon = BADGE_ICON_LARGE;
+
/**
* Structure to encapsulate a named action that can be shown as part of this notification.
* It must include an icon, a label, and a {@link PendingIntent} to be fired when the action is
mChannelId = parcel.readString();
}
mTimeout = parcel.readLong();
+
+ if (parcel.readInt() != 0) {
+ mShortcutId = parcel.readString();
+ }
+
+ mBadgeIcon = parcel.readInt();
}
@Override
}
try {
// IMPORTANT: Add marshaling code in writeToParcelImpl as we
- // want to intercept all pending events written to the pacel.
+ // want to intercept all pending events written to the parcel.
writeToParcelImpl(parcel, flags);
// Must be written last!
parcel.writeArraySet(allPendingIntents);
parcel.writeInt(0);
}
parcel.writeLong(mTimeout);
+
+ if (mShortcutId != null) {
+ parcel.writeInt(1);
+ parcel.writeString(mShortcutId);
+ } else {
+ parcel.writeInt(0);
+ }
+
+ parcel.writeInt(mBadgeIcon);
}
/**
}
/**
- * Returns the time at which this notification should be canceled, if it's not canceled already.
+ * Returns the time at which this notification should be canceled by the system, if it's not
+ * canceled already.
*/
public long getTimeout() {
return mTimeout;
}
/**
+ * Returns what icon should be shown for this notification if it is being displayed in a
+ * Launcher that supports badging. Will be one of {@link #BADGE_ICON_NONE},
+ * {@link #BADGE_ICON_SMALL}, or {@link #BADGE_ICON_LARGE}.
+ */
+ public int getBadgeIcon() {
+ return mBadgeIcon;
+ }
+
+ /**
+ * Returns the {@link ShortcutInfo#getId() id} that this notification supersedes, if any.
+ */
+ public String getShortcutId() {
+ return mShortcutId;
+ }
+
+ /**
* The small icon representing this notification in the status bar and content view.
*
* @return the small icon representing this notification.
}
/**
+ * If this notification is duplicative of a Launcher shortcut, sets the
+ * {@link ShortcutInfo#getId() id} of the shortcut, in case the Launcher wants to hide
+ * the shortcut.
+ *
+ * This field will be ignored by Launchers that don't support badging or
+ * {@link android.content.pm.ShortcutManager shortcuts}.
+ *
+ * @param shortcutId the {@link ShortcutInfo#getId() id} of the shortcut this notification
+ * supersedes
+ */
+ public Builder setShortcutId(String shortcutId) {
+ mN.mShortcutId = shortcutId;
+ return this;
+ }
+
+ /**
+ * Sets which icon to display as a badge for this notification.
+ *
+ * Must be one of {@link #BADGE_ICON_NONE}, {@link #BADGE_ICON_SMALL},
+ * {@link #BADGE_ICON_LARGE}.
+ *
+ * Note: This value might be ignored, for launchers that don't support badge icons.
+ */
+ public Builder chooseBadgeIcon(int icon) {
+ mN.mBadgeIcon = icon;
+ return this;
+ }
+
+ /**
* Specifies the channel the notification should be delivered on.
*/
public Builder setChannel(String channelId) {
}
/**
- * Set the large number at the right-hand side of the notification. This is
- * equivalent to setContentInfo, although it might show the number in a different
- * font size for readability.
- *
- * @deprecated this number is not shown anywhere anymore
+ * Sets the number of items this notification represents. May be displayed as a badge count
+ * for Launchers that support badging.
*/
- @Deprecated
public Builder setNumber(int number) {
mN.number = number;
return this;