diff --git a/api/current.txt b/api/current.txt index 829df43d95a45..e50a72b1c7b81 100644 --- a/api/current.txt +++ b/api/current.txt @@ -5197,7 +5197,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 84efdf7fbd7cd..d1ecf956ffe98 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5360,7 +5360,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 28b9af1c6ff0d..556bd4179f815 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -5207,7 +5207,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 34d2039988e68..7bdf4cc158522 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -2486,9 +2486,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); } /**