diff --git a/api/current.txt b/api/current.txt index 8cd4704abfff8..d025f1895e577 100644 --- a/api/current.txt +++ b/api/current.txt @@ -5176,7 +5176,8 @@ package android.app { } public static class Notification.Builder { - ctor public Notification.Builder(android.content.Context); + ctor public Notification.Builder(android.content.Context, java.lang.String); + ctor public deprecated Notification.Builder(android.content.Context); method public deprecated android.app.Notification.Builder addAction(int, java.lang.CharSequence, android.app.PendingIntent); method public android.app.Notification.Builder addAction(android.app.Notification.Action); method public android.app.Notification.Builder addExtras(android.os.Bundle); diff --git a/api/system-current.txt b/api/system-current.txt index d5096a59e78a2..048f4edfd671e 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5336,7 +5336,8 @@ package android.app { } public static class Notification.Builder { - ctor public Notification.Builder(android.content.Context); + ctor public Notification.Builder(android.content.Context, java.lang.String); + ctor public deprecated Notification.Builder(android.content.Context); method public deprecated android.app.Notification.Builder addAction(int, java.lang.CharSequence, android.app.PendingIntent); method public android.app.Notification.Builder addAction(android.app.Notification.Action); method public android.app.Notification.Builder addExtras(android.os.Bundle); diff --git a/api/test-current.txt b/api/test-current.txt index 4103cda2adc10..d647b14f51356 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -5186,7 +5186,8 @@ package android.app { } public static class Notification.Builder { - ctor public Notification.Builder(android.content.Context); + ctor public Notification.Builder(android.content.Context, java.lang.String); + ctor public deprecated Notification.Builder(android.content.Context); method public deprecated android.app.Notification.Builder addAction(int, java.lang.CharSequence, android.app.PendingIntent); method public android.app.Notification.Builder addAction(android.app.Notification.Action); method public android.app.Notification.Builder addExtras(android.os.Bundle); diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 5b74e23da7c90..0cc4839793e47 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -2451,9 +2451,23 @@ public class Notification implements Parcelable * A {@link Context} that will be used by the Builder to construct the * RemoteViews. The Context will not be held past the lifetime of this Builder * object. + * @param channelId + * The constructed Notification will be posted on this + * {@link NotificationChannel}. To use a NotificationChannel, it must first be + * created using {@link NotificationManager#createNotificationChannel}. */ + public Builder(Context context, String channelId) { + this(context, (Notification) null); + mN.mChannelId = channelId; + } + + /** + * @deprecated use {@link Notification.Builder#Notification.Builder(Context, String)} + * instead. All posted Notifications must specify a NotificationChannel Id. + */ + @Deprecated public Builder(Context context) { - this(context, null); + this(context, (Notification) null); } /**