NotificationCompat.java revision b41a213761ff07de2fcfdaf16790fdcca1a1ee1b
1c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell/* 2c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Copyright (C) 2012 The Android Open Source Project 3c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * 4c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Licensed under the Apache License, Version 2.0 (the "License"); 5c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * you may not use this file except in compliance with the License. 6c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * You may obtain a copy of the License at 7c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * 8c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * http://www.apache.org/licenses/LICENSE-2.0 9c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * 10c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Unless required by applicable law or agreed to in writing, software 11c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * distributed under the License is distributed on an "AS IS" BASIS, 12c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * See the License for the specific language governing permissions and 14c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * limitations under the License. 15c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 16c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 17c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powellpackage android.support.v4.app; 18c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 19c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powellimport android.app.Notification; 20c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powellimport android.app.NotificationManager; 21c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powellimport android.app.PendingIntent; 22c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powellimport android.content.Context; 23c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powellimport android.graphics.Bitmap; 24c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powellimport android.media.AudioManager; 25c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powellimport android.net.Uri; 26c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powellimport android.os.Build; 27c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powellimport android.widget.RemoteViews; 28f021758934b35e3b842c6799344531d7ea2969daChris Wrenimport java.util.ArrayList; 29c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 30c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powellpublic class NotificationCompat { 31c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 32f021758934b35e3b842c6799344531d7ea2969daChris Wren * Obsolete flag indicating high-priority notifications; use the priority field instead. 33f021758934b35e3b842c6799344531d7ea2969daChris Wren * 34f021758934b35e3b842c6799344531d7ea2969daChris Wren * @deprecated Use {@link NotificationCompat.Builder#setPriority(int)} with a positive value. 35c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 36c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public static final int FLAG_HIGH_PRIORITY = 0x00000080; 37c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 38f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 39f021758934b35e3b842c6799344531d7ea2969daChris Wren * Default notification priority for {@link NotificationCompat.Builder#setPriority(int)}. 40f021758934b35e3b842c6799344531d7ea2969daChris Wren * If your application does not prioritize its own notifications, 41f021758934b35e3b842c6799344531d7ea2969daChris Wren * use this value for all notifications. 42f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 43f021758934b35e3b842c6799344531d7ea2969daChris Wren public static final int PRIORITY_DEFAULT = 0; 44f021758934b35e3b842c6799344531d7ea2969daChris Wren 45f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 46f021758934b35e3b842c6799344531d7ea2969daChris Wren * Lower notification priority for {@link NotificationCompat.Builder#setPriority(int)}, 47f021758934b35e3b842c6799344531d7ea2969daChris Wren * for items that are less important. The UI may choose to show 48f021758934b35e3b842c6799344531d7ea2969daChris Wren * these items smaller, or at a different position in the list, 49f021758934b35e3b842c6799344531d7ea2969daChris Wren * compared with your app's {@link #PRIORITY_DEFAULT} items. 50f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 51f021758934b35e3b842c6799344531d7ea2969daChris Wren public static final int PRIORITY_LOW = -1; 52f021758934b35e3b842c6799344531d7ea2969daChris Wren 53f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 54f021758934b35e3b842c6799344531d7ea2969daChris Wren * Lowest notification priority for {@link NotificationCompat.Builder#setPriority(int)}; 55f021758934b35e3b842c6799344531d7ea2969daChris Wren * these items might not be shown to the user except under 56f021758934b35e3b842c6799344531d7ea2969daChris Wren * special circumstances, such as detailed notification logs. 57f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 58f021758934b35e3b842c6799344531d7ea2969daChris Wren public static final int PRIORITY_MIN = -2; 59f021758934b35e3b842c6799344531d7ea2969daChris Wren 60f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 61f021758934b35e3b842c6799344531d7ea2969daChris Wren * Higher notification priority for {@link NotificationCompat.Builder#setPriority(int)}, 62f021758934b35e3b842c6799344531d7ea2969daChris Wren * for more important notifications or alerts. The UI may choose 63f021758934b35e3b842c6799344531d7ea2969daChris Wren * to show these items larger, or at a different position in 64f021758934b35e3b842c6799344531d7ea2969daChris Wren * notification lists, compared with your app's {@link #PRIORITY_DEFAULT} items. 65f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 66f021758934b35e3b842c6799344531d7ea2969daChris Wren public static final int PRIORITY_HIGH = 1; 67f021758934b35e3b842c6799344531d7ea2969daChris Wren 68f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 69f021758934b35e3b842c6799344531d7ea2969daChris Wren * Highest notification priority for {@link NotificationCompat.Builder#setPriority(int)}, 70f021758934b35e3b842c6799344531d7ea2969daChris Wren * for your application's most important items that require the user's 71f021758934b35e3b842c6799344531d7ea2969daChris Wren * prompt attention or input. 72f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 73f021758934b35e3b842c6799344531d7ea2969daChris Wren public static final int PRIORITY_MAX = 2; 74f021758934b35e3b842c6799344531d7ea2969daChris Wren 75c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell private static final NotificationCompatImpl IMPL; 76c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 77c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell interface NotificationCompatImpl { 78f021758934b35e3b842c6799344531d7ea2969daChris Wren public Notification build(Builder b); 79c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 80c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 81c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell static class NotificationCompatImplBase implements NotificationCompatImpl { 82f021758934b35e3b842c6799344531d7ea2969daChris Wren public Notification build(Builder b) { 83c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell Notification result = (Notification) b.mNotification; 84c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell result.setLatestEventInfo(b.mContext, b.mContentTitle, 85c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell b.mContentText, b.mContentIntent); 86f021758934b35e3b842c6799344531d7ea2969daChris Wren // translate high priority requests into legacy flag 87f021758934b35e3b842c6799344531d7ea2969daChris Wren if (b.mPriority > PRIORITY_DEFAULT) { 88f021758934b35e3b842c6799344531d7ea2969daChris Wren result.flags |= FLAG_HIGH_PRIORITY; 89f021758934b35e3b842c6799344531d7ea2969daChris Wren } 90c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return result; 91c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 92c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 93c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 94c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell static class NotificationCompatImplHoneycomb implements NotificationCompatImpl { 95f021758934b35e3b842c6799344531d7ea2969daChris Wren public Notification build(Builder b) { 96c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return NotificationCompatHoneycomb.add(b.mContext, b.mNotification, 97c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell b.mContentTitle, b.mContentText, b.mContentInfo, b.mTickerView, 98c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell b.mNumber, b.mContentIntent, b.mFullScreenIntent, b.mLargeIcon); 99c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 100c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 101c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 102f021758934b35e3b842c6799344531d7ea2969daChris Wren static class NotificationCompatImplIceCreamSandwich implements NotificationCompatImpl { 103f021758934b35e3b842c6799344531d7ea2969daChris Wren public Notification build(Builder b) { 104f021758934b35e3b842c6799344531d7ea2969daChris Wren return NotificationCompatIceCreamSandwich.add(b.mContext, b.mNotification, 105f021758934b35e3b842c6799344531d7ea2969daChris Wren b.mContentTitle, b.mContentText, b.mContentInfo, b.mTickerView, 106f021758934b35e3b842c6799344531d7ea2969daChris Wren b.mNumber, b.mContentIntent, b.mFullScreenIntent, b.mLargeIcon, 107f021758934b35e3b842c6799344531d7ea2969daChris Wren b.mProgressMax, b.mProgress, b.mProgressIndeterminate); 108f021758934b35e3b842c6799344531d7ea2969daChris Wren } 109f021758934b35e3b842c6799344531d7ea2969daChris Wren } 110f021758934b35e3b842c6799344531d7ea2969daChris Wren 111f021758934b35e3b842c6799344531d7ea2969daChris Wren static class NotificationCompatImplJellybean implements NotificationCompatImpl { 112f021758934b35e3b842c6799344531d7ea2969daChris Wren public Notification build(Builder b) { 113f021758934b35e3b842c6799344531d7ea2969daChris Wren NotificationCompatJellybean jbBuilder = new NotificationCompatJellybean( 114f021758934b35e3b842c6799344531d7ea2969daChris Wren b.mContext, b.mNotification, b.mContentTitle, b.mContentText, b.mContentInfo, 115f021758934b35e3b842c6799344531d7ea2969daChris Wren b.mTickerView, b.mNumber, b.mContentIntent, b.mFullScreenIntent, b.mLargeIcon, 116f021758934b35e3b842c6799344531d7ea2969daChris Wren b.mProgressMax, b.mProgress, b.mProgressIndeterminate, 117f021758934b35e3b842c6799344531d7ea2969daChris Wren b.mUseChronometer, b.mPriority, b.mSubText); 118f021758934b35e3b842c6799344531d7ea2969daChris Wren for (Action action: b.mActions) { 119f021758934b35e3b842c6799344531d7ea2969daChris Wren jbBuilder.addAction(action.icon, action.title, action.actionIntent); 120f021758934b35e3b842c6799344531d7ea2969daChris Wren } 121f021758934b35e3b842c6799344531d7ea2969daChris Wren if (b.mStyle != null) { 122f021758934b35e3b842c6799344531d7ea2969daChris Wren if (b.mStyle instanceof BigTextStyle) { 123f021758934b35e3b842c6799344531d7ea2969daChris Wren BigTextStyle style = (BigTextStyle) b.mStyle; 124f021758934b35e3b842c6799344531d7ea2969daChris Wren jbBuilder.addBigTextStyle(style.mBigContentTitle, 125f021758934b35e3b842c6799344531d7ea2969daChris Wren style.mSummaryTextSet, 126f021758934b35e3b842c6799344531d7ea2969daChris Wren style.mSummaryText, 127f021758934b35e3b842c6799344531d7ea2969daChris Wren style.mBigText); 128f021758934b35e3b842c6799344531d7ea2969daChris Wren } else if (b.mStyle instanceof InboxStyle) { 129f021758934b35e3b842c6799344531d7ea2969daChris Wren InboxStyle style = (InboxStyle) b.mStyle; 130f021758934b35e3b842c6799344531d7ea2969daChris Wren jbBuilder.addInboxStyle(style.mBigContentTitle, 131f021758934b35e3b842c6799344531d7ea2969daChris Wren style.mSummaryTextSet, 132f021758934b35e3b842c6799344531d7ea2969daChris Wren style.mSummaryText, 133f021758934b35e3b842c6799344531d7ea2969daChris Wren style.mTexts); 134f021758934b35e3b842c6799344531d7ea2969daChris Wren } else if (b.mStyle instanceof BigPictureStyle) { 135f021758934b35e3b842c6799344531d7ea2969daChris Wren BigPictureStyle style = (BigPictureStyle) b.mStyle; 136f021758934b35e3b842c6799344531d7ea2969daChris Wren jbBuilder.addBigPictureStyle(style.mBigContentTitle, 137f021758934b35e3b842c6799344531d7ea2969daChris Wren style.mSummaryTextSet, 138f021758934b35e3b842c6799344531d7ea2969daChris Wren style.mSummaryText, 139f021758934b35e3b842c6799344531d7ea2969daChris Wren style.mPicture); 140f021758934b35e3b842c6799344531d7ea2969daChris Wren } 141f021758934b35e3b842c6799344531d7ea2969daChris Wren } 142f021758934b35e3b842c6799344531d7ea2969daChris Wren return(jbBuilder.build()); 143f021758934b35e3b842c6799344531d7ea2969daChris Wren } 144f021758934b35e3b842c6799344531d7ea2969daChris Wren } 145f021758934b35e3b842c6799344531d7ea2969daChris Wren 146c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell static { 147f021758934b35e3b842c6799344531d7ea2969daChris Wren if (Build.VERSION.SDK_INT >= 16) { 148f021758934b35e3b842c6799344531d7ea2969daChris Wren IMPL = new NotificationCompatImplJellybean(); 149f021758934b35e3b842c6799344531d7ea2969daChris Wren } else if (Build.VERSION.SDK_INT >= 13) { 150f021758934b35e3b842c6799344531d7ea2969daChris Wren IMPL = new NotificationCompatImplIceCreamSandwich(); 151f021758934b35e3b842c6799344531d7ea2969daChris Wren } else if (Build.VERSION.SDK_INT >= 11) { 152c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell IMPL = new NotificationCompatImplHoneycomb(); 153c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } else { 154c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell IMPL = new NotificationCompatImplBase(); 155c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 156c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 157c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 158c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 159c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Builder class for {@link Notification} objects. Allows easier control over 160c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * all the flags, as well as help constructing the typical notification layouts. 161c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 162c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public static class Builder { 163c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell Context mContext; 164c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 165c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell CharSequence mContentTitle; 166c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell CharSequence mContentText; 167c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell PendingIntent mContentIntent; 168c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell PendingIntent mFullScreenIntent; 169c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell RemoteViews mTickerView; 170c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell Bitmap mLargeIcon; 171c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell CharSequence mContentInfo; 172c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell int mNumber; 173f021758934b35e3b842c6799344531d7ea2969daChris Wren int mPriority; 174f021758934b35e3b842c6799344531d7ea2969daChris Wren boolean mUseChronometer; 175f021758934b35e3b842c6799344531d7ea2969daChris Wren Style mStyle; 176f021758934b35e3b842c6799344531d7ea2969daChris Wren CharSequence mSubText; 177f021758934b35e3b842c6799344531d7ea2969daChris Wren int mProgressMax; 178f021758934b35e3b842c6799344531d7ea2969daChris Wren int mProgress; 179f021758934b35e3b842c6799344531d7ea2969daChris Wren boolean mProgressIndeterminate; 180f021758934b35e3b842c6799344531d7ea2969daChris Wren ArrayList<Action> mActions = new ArrayList<Action>(); 181c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 182c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell Notification mNotification = new Notification(); 183c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 184c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 185c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Constructor. 186c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * 187c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Automatically sets the when field to {@link System#currentTimeMillis() 188c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * System.currentTimeMillis()} and the audio stream to the 189c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * {@link Notification#STREAM_DEFAULT}. 190c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * 191c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * @param context A {@link Context} that will be used to construct the 192c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * RemoteViews. The Context will not be held past the lifetime of this 193c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Builder object. 194c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 195c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder(Context context) { 196c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mContext = context; 197c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 198c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell // Set defaults to match the defaults of a Notification 199c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.when = System.currentTimeMillis(); 200c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.audioStreamType = Notification.STREAM_DEFAULT; 201f021758934b35e3b842c6799344531d7ea2969daChris Wren mPriority = PRIORITY_DEFAULT; 202c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 203c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 204c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 205c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set the time that the event occurred. Notifications in the panel are 206c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * sorted by this time. 207c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 208c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setWhen(long when) { 209c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.when = when; 210c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 211c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 212c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 213c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 214f021758934b35e3b842c6799344531d7ea2969daChris Wren * Show the {@link Notification#when} field as a stopwatch. 215f021758934b35e3b842c6799344531d7ea2969daChris Wren * 216f021758934b35e3b842c6799344531d7ea2969daChris Wren * Instead of presenting <code>when</code> as a timestamp, the notification will show an 217f021758934b35e3b842c6799344531d7ea2969daChris Wren * automatically updating display of the minutes and seconds since <code>when</code>. 218f021758934b35e3b842c6799344531d7ea2969daChris Wren * 219f021758934b35e3b842c6799344531d7ea2969daChris Wren * Useful when showing an elapsed time (like an ongoing phone call). 220f021758934b35e3b842c6799344531d7ea2969daChris Wren * 221f021758934b35e3b842c6799344531d7ea2969daChris Wren * @see android.widget.Chronometer 222f021758934b35e3b842c6799344531d7ea2969daChris Wren * @see Notification#when 223f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 224f021758934b35e3b842c6799344531d7ea2969daChris Wren public Builder setUsesChronometer(boolean b) { 225f021758934b35e3b842c6799344531d7ea2969daChris Wren mUseChronometer = b; 226f021758934b35e3b842c6799344531d7ea2969daChris Wren return this; 227f021758934b35e3b842c6799344531d7ea2969daChris Wren } 228f021758934b35e3b842c6799344531d7ea2969daChris Wren 229f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 230c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set the small icon to use in the notification layouts. Different classes of devices 231c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * may return different sizes. See the UX guidelines for more information on how to 232c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * design these icons. 233c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * 234c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * @param icon A resource ID in the application's package of the drawble to use. 235c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 236c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setSmallIcon(int icon) { 237c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.icon = icon; 238c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 239c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 240c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 241c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 242c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * A variant of {@link #setSmallIcon(int) setSmallIcon(int)} that takes an additional 243c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * level parameter for when the icon is a {@link android.graphics.drawable.LevelListDrawable 244c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * LevelListDrawable}. 245c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * 246c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * @param icon A resource ID in the application's package of the drawble to use. 247c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * @param level The level to use for the icon. 248c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * 249c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * @see android.graphics.drawable.LevelListDrawable 250c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 251c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setSmallIcon(int icon, int level) { 252c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.icon = icon; 253c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.iconLevel = level; 254c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 255c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 256c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 257c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 258c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set the title (first row) of the notification, in a standard notification. 259c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 260c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setContentTitle(CharSequence title) { 261c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mContentTitle = title; 262c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 263c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 264c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 265c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 266c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set the text (second row) of the notification, in a standard notification. 267c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 268c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setContentText(CharSequence text) { 269c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mContentText = text; 270c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 271c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 272c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 273c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 274f021758934b35e3b842c6799344531d7ea2969daChris Wren * Set the third line of text in the platform notification template. 275f021758934b35e3b842c6799344531d7ea2969daChris Wren * Don't use if you're also using {@link #setProgress(int, int, boolean)}; 276f021758934b35e3b842c6799344531d7ea2969daChris Wren * they occupy the same location in the standard template. 277f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 278f021758934b35e3b842c6799344531d7ea2969daChris Wren public Builder setSubText(CharSequence text) { 279f021758934b35e3b842c6799344531d7ea2969daChris Wren mSubText = text; 280f021758934b35e3b842c6799344531d7ea2969daChris Wren return this; 281f021758934b35e3b842c6799344531d7ea2969daChris Wren } 282f021758934b35e3b842c6799344531d7ea2969daChris Wren 283f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 284c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set the large number at the right-hand side of the notification. This is 285c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * equivalent to setContentInfo, although it might show the number in a different 286c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * font size for readability. 287c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 288c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setNumber(int number) { 289c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNumber = number; 290c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 291c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 292c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 293c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 294c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set the large text at the right-hand side of the notification. 295c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 296c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setContentInfo(CharSequence info) { 297c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mContentInfo = info; 298c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 299c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 300c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 301c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 302c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set the progress this notification represents, which may be 303f021758934b35e3b842c6799344531d7ea2969daChris Wren * represented as a {@link android.widget.ProgressBar}. 304c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 305c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setProgress(int max, int progress, boolean indeterminate) { 306c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mProgressMax = max; 307c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mProgress = progress; 308c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mProgressIndeterminate = indeterminate; 309c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 310f021758934b35e3b842c6799344531d7ea2969daChris Wren } 311c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 312c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 313c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Supply a custom RemoteViews to use instead of the standard one. 314c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 315c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setContent(RemoteViews views) { 316c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.contentView = views; 317c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 318c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 319c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 320c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 321c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Supply a {@link PendingIntent} to send when the notification is clicked. 322c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * If you do not supply an intent, you can now add PendingIntents to individual 323c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * views to be launched when clicked by calling {@link RemoteViews#setOnClickPendingIntent 324c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * RemoteViews.setOnClickPendingIntent(int,PendingIntent)}. Be sure to 325c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * read {@link Notification#contentIntent Notification.contentIntent} for 326c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * how to correctly use this. 327c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 328c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setContentIntent(PendingIntent intent) { 329c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mContentIntent = intent; 330c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 331c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 332c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 333c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 334c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Supply a {@link PendingIntent} to send when the notification is cleared by the user 335c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * directly from the notification panel. For example, this intent is sent when the user 336c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * clicks the "Clear all" button, or the individual "X" buttons on notifications. This 337c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * intent is not sent when the application calls {@link NotificationManager#cancel 338c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * NotificationManager.cancel(int)}. 339c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 340c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setDeleteIntent(PendingIntent intent) { 341c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.deleteIntent = intent; 342c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 343c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 344c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 345c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 346c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * An intent to launch instead of posting the notification to the status bar. 347c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Only for use with extremely high-priority notifications demanding the user's 348c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * <strong>immediate</strong> attention, such as an incoming phone call or 349c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * alarm clock that the user has explicitly set to a particular time. 350c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * If this facility is used for something else, please give the user an option 351c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * to turn it off and use a normal notification, as this can be extremely 352c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * disruptive. 353c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * 354c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * @param intent The pending intent to launch. 355c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * @param highPriority Passing true will cause this notification to be sent 356c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * even if other notifications are suppressed. 357c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 358c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setFullScreenIntent(PendingIntent intent, boolean highPriority) { 359c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mFullScreenIntent = intent; 360c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell setFlag(FLAG_HIGH_PRIORITY, highPriority); 361c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 362c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 363c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 364c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 365c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set the text that is displayed in the status bar when the notification first 366c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * arrives. 367c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 368c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setTicker(CharSequence tickerText) { 369c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.tickerText = tickerText; 370c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 371c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 372c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 373c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 374c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set the text that is displayed in the status bar when the notification first 375c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * arrives, and also a RemoteViews object that may be displayed instead on some 376c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * devices. 377c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 378c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setTicker(CharSequence tickerText, RemoteViews views) { 379c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.tickerText = tickerText; 380c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mTickerView = views; 381c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 382c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 383c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 384c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 385c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set the large icon that is shown in the ticker and notification. 386c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 387c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setLargeIcon(Bitmap icon) { 388c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mLargeIcon = icon; 389c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 390c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 391c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 392c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 393c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set the sound to play. It will play on the default stream. 394c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 395c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setSound(Uri sound) { 396c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.sound = sound; 397c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.audioStreamType = Notification.STREAM_DEFAULT; 398c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 399c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 400c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 401c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 402c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set the sound to play. It will play on the stream you supply. 403c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * 404c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * @see #STREAM_DEFAULT 405c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * @see AudioManager for the <code>STREAM_</code> constants. 406c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 407c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setSound(Uri sound, int streamType) { 408c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.sound = sound; 409c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.audioStreamType = streamType; 410c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 411c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 412c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 413c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 414c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set the vibration pattern to use. 415c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * 416c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * @see android.os.Vibrator for a discussion of the <code>pattern</code> 417c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * parameter. 418c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 419c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setVibrate(long[] pattern) { 420c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.vibrate = pattern; 421c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 422c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 423c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 424c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 425c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set the argb value that you would like the LED on the device to blnk, as well as the 426c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * rate. The rate is specified in terms of the number of milliseconds to be on 427c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * and then the number of milliseconds to be off. 428c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 429c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setLights(int argb, int onMs, int offMs) { 430c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.ledARGB = argb; 431c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.ledOnMS = onMs; 432c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.ledOffMS = offMs; 433c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell boolean showLights = mNotification.ledOnMS != 0 && mNotification.ledOffMS != 0; 434c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.flags = (mNotification.flags & ~Notification.FLAG_SHOW_LIGHTS) | 435c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell (showLights ? Notification.FLAG_SHOW_LIGHTS : 0); 436c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 437c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 438c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 439c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 440c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set whether this is an ongoing notification. 441c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * 442c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * <p>Ongoing notifications differ from regular notifications in the following ways: 443c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * <ul> 444c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * <li>Ongoing notifications are sorted above the regular notifications in the 445c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * notification panel.</li> 446c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * <li>Ongoing notifications do not have an 'X' close button, and are not affected 447c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * by the "Clear all" button. 448c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * </ul> 449c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 450c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setOngoing(boolean ongoing) { 451c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell setFlag(Notification.FLAG_ONGOING_EVENT, ongoing); 452c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 453c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 454c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 455c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 456c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set this flag if you would only like the sound, vibrate 457c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * and ticker to be played if the notification is not already showing. 458c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 459c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setOnlyAlertOnce(boolean onlyAlertOnce) { 460c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell setFlag(Notification.FLAG_ONLY_ALERT_ONCE, onlyAlertOnce); 461c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 462c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 463c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 464c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 465c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Setting this flag will make it so the notification is automatically 466c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * canceled when the user clicks it in the panel. The PendingIntent 467c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * set with {@link #setDeleteIntent} will be broadcast when the notification 468c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * is canceled. 469c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 470c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setAutoCancel(boolean autoCancel) { 471c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell setFlag(Notification.FLAG_AUTO_CANCEL, autoCancel); 472c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 473c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 474c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 475c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 476c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Set the default notification options that will be used. 477c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * <p> 478c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * The value should be one or more of the following fields combined with 479c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * bitwise-or: 480c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * {@link Notification#DEFAULT_SOUND}, {@link Notification#DEFAULT_VIBRATE}, 481c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * {@link Notification#DEFAULT_LIGHTS}. 482c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * <p> 483c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * For all default values, use {@link Notification#DEFAULT_ALL}. 484c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 485c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell public Builder setDefaults(int defaults) { 486c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.defaults = defaults; 487c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell if ((defaults & Notification.DEFAULT_LIGHTS) != 0) { 488c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.flags |= Notification.FLAG_SHOW_LIGHTS; 489c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 490c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell return this; 491c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 492c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 493c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell private void setFlag(int mask, boolean value) { 494c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell if (value) { 495c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.flags |= mask; 496c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } else { 497c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell mNotification.flags &= ~mask; 498c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 499c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 500c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell 501c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell /** 502f021758934b35e3b842c6799344531d7ea2969daChris Wren * Set the relative priority for this notification. 503f021758934b35e3b842c6799344531d7ea2969daChris Wren * 504f021758934b35e3b842c6799344531d7ea2969daChris Wren * Priority is an indication of how much of the user's 505f021758934b35e3b842c6799344531d7ea2969daChris Wren * valuable attention should be consumed by this 506f021758934b35e3b842c6799344531d7ea2969daChris Wren * notification. Low-priority notifications may be hidden from 507f021758934b35e3b842c6799344531d7ea2969daChris Wren * the user in certain situations, while the user might be 508f021758934b35e3b842c6799344531d7ea2969daChris Wren * interrupted for a higher-priority notification. The system 509f021758934b35e3b842c6799344531d7ea2969daChris Wren * will make a determination about how to interpret 510f021758934b35e3b842c6799344531d7ea2969daChris Wren * notification priority as described in MUMBLE MUMBLE. 511f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 512f021758934b35e3b842c6799344531d7ea2969daChris Wren public Builder setPriority(int pri) { 513f021758934b35e3b842c6799344531d7ea2969daChris Wren mPriority = pri; 514f021758934b35e3b842c6799344531d7ea2969daChris Wren return this; 515f021758934b35e3b842c6799344531d7ea2969daChris Wren } 516f021758934b35e3b842c6799344531d7ea2969daChris Wren 517f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 518f021758934b35e3b842c6799344531d7ea2969daChris Wren * Add an action to this notification. Actions are typically displayed by 519f021758934b35e3b842c6799344531d7ea2969daChris Wren * the system as a button adjacent to the notification content. 520f021758934b35e3b842c6799344531d7ea2969daChris Wren * 521f021758934b35e3b842c6799344531d7ea2969daChris Wren * @param icon Resource ID of a drawable that represents the action. 522f021758934b35e3b842c6799344531d7ea2969daChris Wren * @param title Text describing the action. 523f021758934b35e3b842c6799344531d7ea2969daChris Wren * @param intent PendingIntent to be fired when the action is invoked. 524f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 525f021758934b35e3b842c6799344531d7ea2969daChris Wren public Builder addAction(int icon, CharSequence title, PendingIntent intent) { 526f021758934b35e3b842c6799344531d7ea2969daChris Wren mActions.add(new Action(icon, title, intent)); 527f021758934b35e3b842c6799344531d7ea2969daChris Wren return this; 528f021758934b35e3b842c6799344531d7ea2969daChris Wren } 529f021758934b35e3b842c6799344531d7ea2969daChris Wren 530f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 531f021758934b35e3b842c6799344531d7ea2969daChris Wren * Add a rich notification style to be applied at build time. 532f021758934b35e3b842c6799344531d7ea2969daChris Wren * 533f021758934b35e3b842c6799344531d7ea2969daChris Wren * @param style Object responsible for modifying the notification style. 534f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 535f021758934b35e3b842c6799344531d7ea2969daChris Wren public Builder setStyle(Style style) { 536f021758934b35e3b842c6799344531d7ea2969daChris Wren if (mStyle != style) { 537f021758934b35e3b842c6799344531d7ea2969daChris Wren mStyle = style; 538f021758934b35e3b842c6799344531d7ea2969daChris Wren if (mStyle != null) { 539f021758934b35e3b842c6799344531d7ea2969daChris Wren mStyle.setBuilder(this); 540f021758934b35e3b842c6799344531d7ea2969daChris Wren } 541f021758934b35e3b842c6799344531d7ea2969daChris Wren } 542f021758934b35e3b842c6799344531d7ea2969daChris Wren return this; 543f021758934b35e3b842c6799344531d7ea2969daChris Wren } 544f021758934b35e3b842c6799344531d7ea2969daChris Wren 545f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 546f021758934b35e3b842c6799344531d7ea2969daChris Wren * @deprecated Use {@link #build()} instead. 547f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 548f021758934b35e3b842c6799344531d7ea2969daChris Wren @Deprecated 549f021758934b35e3b842c6799344531d7ea2969daChris Wren public Notification getNotification() { 550f021758934b35e3b842c6799344531d7ea2969daChris Wren return (Notification) IMPL.build(this); 551f021758934b35e3b842c6799344531d7ea2969daChris Wren } 552f021758934b35e3b842c6799344531d7ea2969daChris Wren 553f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 554c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * Combine all of the options that have been set and return a new {@link Notification} 555c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell * object. 556c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell */ 557f021758934b35e3b842c6799344531d7ea2969daChris Wren public Notification build() { 558f021758934b35e3b842c6799344531d7ea2969daChris Wren return (Notification) IMPL.build(this); 559f021758934b35e3b842c6799344531d7ea2969daChris Wren } 560f021758934b35e3b842c6799344531d7ea2969daChris Wren } 561f021758934b35e3b842c6799344531d7ea2969daChris Wren 562f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 563f021758934b35e3b842c6799344531d7ea2969daChris Wren * An object that can apply a rich notification style to a {@link Notification.Builder} 564f021758934b35e3b842c6799344531d7ea2969daChris Wren * object. 565f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 566f021758934b35e3b842c6799344531d7ea2969daChris Wren public static abstract class Style 567f021758934b35e3b842c6799344531d7ea2969daChris Wren { 568f021758934b35e3b842c6799344531d7ea2969daChris Wren Builder mBuilder; 569f021758934b35e3b842c6799344531d7ea2969daChris Wren CharSequence mBigContentTitle; 570f021758934b35e3b842c6799344531d7ea2969daChris Wren CharSequence mSummaryText; 571f021758934b35e3b842c6799344531d7ea2969daChris Wren boolean mSummaryTextSet = false; 572f021758934b35e3b842c6799344531d7ea2969daChris Wren 573f021758934b35e3b842c6799344531d7ea2969daChris Wren public void setBuilder(Builder builder) { 574f021758934b35e3b842c6799344531d7ea2969daChris Wren if (mBuilder != builder) { 575f021758934b35e3b842c6799344531d7ea2969daChris Wren mBuilder = builder; 576f021758934b35e3b842c6799344531d7ea2969daChris Wren if (mBuilder != null) { 577f021758934b35e3b842c6799344531d7ea2969daChris Wren mBuilder.setStyle(this); 578f021758934b35e3b842c6799344531d7ea2969daChris Wren } 579f021758934b35e3b842c6799344531d7ea2969daChris Wren } 580f021758934b35e3b842c6799344531d7ea2969daChris Wren } 581f021758934b35e3b842c6799344531d7ea2969daChris Wren 582f021758934b35e3b842c6799344531d7ea2969daChris Wren public Notification build() { 583f021758934b35e3b842c6799344531d7ea2969daChris Wren Notification notification = null; 584f021758934b35e3b842c6799344531d7ea2969daChris Wren if (mBuilder != null) { 585f021758934b35e3b842c6799344531d7ea2969daChris Wren notification = mBuilder.build(); 586f021758934b35e3b842c6799344531d7ea2969daChris Wren } 587f021758934b35e3b842c6799344531d7ea2969daChris Wren return notification; 588f021758934b35e3b842c6799344531d7ea2969daChris Wren } 589f021758934b35e3b842c6799344531d7ea2969daChris Wren } 590f021758934b35e3b842c6799344531d7ea2969daChris Wren 591f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 592f021758934b35e3b842c6799344531d7ea2969daChris Wren * Helper class for generating large-format notifications that include a large image attachment. 593f021758934b35e3b842c6799344531d7ea2969daChris Wren * 594f021758934b35e3b842c6799344531d7ea2969daChris Wren * This class is a "rebuilder": It attaches to a Builder object and modifies its behavior, like so: 595f021758934b35e3b842c6799344531d7ea2969daChris Wren * <pre class="prettyprint"> 596f021758934b35e3b842c6799344531d7ea2969daChris Wren * Notification noti = new Notification.Builder() 597f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setContentTitle("New photo from " + sender.toString()) 598f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setContentText(subject) 599f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setSmallIcon(R.drawable.new_post) 600f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setLargeIcon(aBitmap) 601f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setStyle(new Notification.BigPictureStyle() 602f021758934b35e3b842c6799344531d7ea2969daChris Wren * .bigPicture(aBigBitmap)) 603f021758934b35e3b842c6799344531d7ea2969daChris Wren * .build(); 604f021758934b35e3b842c6799344531d7ea2969daChris Wren * </pre> 605f021758934b35e3b842c6799344531d7ea2969daChris Wren * 606f021758934b35e3b842c6799344531d7ea2969daChris Wren * @see Notification#bigContentView 607f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 608f021758934b35e3b842c6799344531d7ea2969daChris Wren public static class BigPictureStyle extends Style { 609f021758934b35e3b842c6799344531d7ea2969daChris Wren Bitmap mPicture; 610f021758934b35e3b842c6799344531d7ea2969daChris Wren 611f021758934b35e3b842c6799344531d7ea2969daChris Wren public BigPictureStyle() { 612f021758934b35e3b842c6799344531d7ea2969daChris Wren } 613f021758934b35e3b842c6799344531d7ea2969daChris Wren 614f021758934b35e3b842c6799344531d7ea2969daChris Wren public BigPictureStyle(Builder builder) { 615f021758934b35e3b842c6799344531d7ea2969daChris Wren setBuilder(builder); 616f021758934b35e3b842c6799344531d7ea2969daChris Wren } 617f021758934b35e3b842c6799344531d7ea2969daChris Wren 618f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 619f021758934b35e3b842c6799344531d7ea2969daChris Wren * Overrides ContentTitle in the big form of the template. 620f021758934b35e3b842c6799344531d7ea2969daChris Wren * This defaults to the value passed to setContentTitle(). 621f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 622f021758934b35e3b842c6799344531d7ea2969daChris Wren public BigPictureStyle setBigContentTitle(CharSequence title) { 623f021758934b35e3b842c6799344531d7ea2969daChris Wren mBigContentTitle = title; 624f021758934b35e3b842c6799344531d7ea2969daChris Wren return this; 625f021758934b35e3b842c6799344531d7ea2969daChris Wren } 626f021758934b35e3b842c6799344531d7ea2969daChris Wren 627f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 628f021758934b35e3b842c6799344531d7ea2969daChris Wren * Set the first line of text after the detail section in the big form of the template. 629f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 630f021758934b35e3b842c6799344531d7ea2969daChris Wren public BigPictureStyle setSummaryText(CharSequence cs) { 631f021758934b35e3b842c6799344531d7ea2969daChris Wren mSummaryText = cs; 632f021758934b35e3b842c6799344531d7ea2969daChris Wren mSummaryTextSet = true; 633f021758934b35e3b842c6799344531d7ea2969daChris Wren return this; 634f021758934b35e3b842c6799344531d7ea2969daChris Wren } 635f021758934b35e3b842c6799344531d7ea2969daChris Wren 636b41a213761ff07de2fcfdaf16790fdcca1a1ee1bChris Wren /** 637b41a213761ff07de2fcfdaf16790fdcca1a1ee1bChris Wren * Provide the bitmap to be used as the payload for the BigPicture notification. 638b41a213761ff07de2fcfdaf16790fdcca1a1ee1bChris Wren */ 639f021758934b35e3b842c6799344531d7ea2969daChris Wren public BigPictureStyle bigPicture(Bitmap b) { 640f021758934b35e3b842c6799344531d7ea2969daChris Wren mPicture = b; 641f021758934b35e3b842c6799344531d7ea2969daChris Wren return this; 642f021758934b35e3b842c6799344531d7ea2969daChris Wren } 643f021758934b35e3b842c6799344531d7ea2969daChris Wren } 644f021758934b35e3b842c6799344531d7ea2969daChris Wren 645f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 646f021758934b35e3b842c6799344531d7ea2969daChris Wren * Helper class for generating large-format notifications that include a lot of text. 647f021758934b35e3b842c6799344531d7ea2969daChris Wren * 648f021758934b35e3b842c6799344531d7ea2969daChris Wren * This class is a "rebuilder": It attaches to a Builder object and modifies its behavior, like so: 649f021758934b35e3b842c6799344531d7ea2969daChris Wren * <pre class="prettyprint"> 650f021758934b35e3b842c6799344531d7ea2969daChris Wren * Notification noti = new Notification.Builder() 651f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setContentTitle("New mail from " + sender.toString()) 652f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setContentText(subject) 653f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setSmallIcon(R.drawable.new_mail) 654f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setLargeIcon(aBitmap) 655f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setStyle(new Notification.BigTextStyle() 656f021758934b35e3b842c6799344531d7ea2969daChris Wren * .bigText(aVeryLongString)) 657f021758934b35e3b842c6799344531d7ea2969daChris Wren * .build(); 658f021758934b35e3b842c6799344531d7ea2969daChris Wren * </pre> 659f021758934b35e3b842c6799344531d7ea2969daChris Wren * 660f021758934b35e3b842c6799344531d7ea2969daChris Wren * @see Notification#bigContentView 661f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 662f021758934b35e3b842c6799344531d7ea2969daChris Wren public static class BigTextStyle extends Style { 663f021758934b35e3b842c6799344531d7ea2969daChris Wren CharSequence mBigText; 664f021758934b35e3b842c6799344531d7ea2969daChris Wren 665f021758934b35e3b842c6799344531d7ea2969daChris Wren public BigTextStyle() { 666f021758934b35e3b842c6799344531d7ea2969daChris Wren } 667f021758934b35e3b842c6799344531d7ea2969daChris Wren 668f021758934b35e3b842c6799344531d7ea2969daChris Wren public BigTextStyle(Builder builder) { 669f021758934b35e3b842c6799344531d7ea2969daChris Wren setBuilder(builder); 670f021758934b35e3b842c6799344531d7ea2969daChris Wren } 671f021758934b35e3b842c6799344531d7ea2969daChris Wren 672f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 673f021758934b35e3b842c6799344531d7ea2969daChris Wren * Overrides ContentTitle in the big form of the template. 674f021758934b35e3b842c6799344531d7ea2969daChris Wren * This defaults to the value passed to setContentTitle(). 675f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 676f021758934b35e3b842c6799344531d7ea2969daChris Wren public BigTextStyle setBigContentTitle(CharSequence title) { 677f021758934b35e3b842c6799344531d7ea2969daChris Wren mBigContentTitle = title; 678f021758934b35e3b842c6799344531d7ea2969daChris Wren return this; 679f021758934b35e3b842c6799344531d7ea2969daChris Wren } 680f021758934b35e3b842c6799344531d7ea2969daChris Wren 681f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 682f021758934b35e3b842c6799344531d7ea2969daChris Wren * Set the first line of text after the detail section in the big form of the template. 683f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 684f021758934b35e3b842c6799344531d7ea2969daChris Wren public BigTextStyle setSummaryText(CharSequence cs) { 685f021758934b35e3b842c6799344531d7ea2969daChris Wren mSummaryText = cs; 686f021758934b35e3b842c6799344531d7ea2969daChris Wren mSummaryTextSet = true; 687f021758934b35e3b842c6799344531d7ea2969daChris Wren return this; 688f021758934b35e3b842c6799344531d7ea2969daChris Wren } 689f021758934b35e3b842c6799344531d7ea2969daChris Wren 690b41a213761ff07de2fcfdaf16790fdcca1a1ee1bChris Wren /** 691b41a213761ff07de2fcfdaf16790fdcca1a1ee1bChris Wren * Provide the longer text to be displayed in the big form of the 692b41a213761ff07de2fcfdaf16790fdcca1a1ee1bChris Wren * template in place of the content text. 693b41a213761ff07de2fcfdaf16790fdcca1a1ee1bChris Wren */ 694f021758934b35e3b842c6799344531d7ea2969daChris Wren public BigTextStyle bigText(CharSequence cs) { 695f021758934b35e3b842c6799344531d7ea2969daChris Wren mBigText = cs; 696f021758934b35e3b842c6799344531d7ea2969daChris Wren return this; 697f021758934b35e3b842c6799344531d7ea2969daChris Wren } 698f021758934b35e3b842c6799344531d7ea2969daChris Wren } 699f021758934b35e3b842c6799344531d7ea2969daChris Wren 700f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 701f021758934b35e3b842c6799344531d7ea2969daChris Wren * Helper class for generating large-format notifications that include a list of (up to 5) strings. 702f021758934b35e3b842c6799344531d7ea2969daChris Wren * 703f021758934b35e3b842c6799344531d7ea2969daChris Wren * This class is a "rebuilder": It attaches to a Builder object and modifies its behavior, like so: 704f021758934b35e3b842c6799344531d7ea2969daChris Wren * <pre class="prettyprint"> 705f021758934b35e3b842c6799344531d7ea2969daChris Wren * Notification noti = new Notification.Builder() 706f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setContentTitle("5 New mails from " + sender.toString()) 707f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setContentText(subject) 708f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setSmallIcon(R.drawable.new_mail) 709f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setLargeIcon(aBitmap) 710f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setStyle(new Notification.InboxStyle() 711f021758934b35e3b842c6799344531d7ea2969daChris Wren * .addLine(str1) 712f021758934b35e3b842c6799344531d7ea2969daChris Wren * .addLine(str2) 713f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setContentTitle("") 714f021758934b35e3b842c6799344531d7ea2969daChris Wren * .setSummaryText("+3 more")) 715f021758934b35e3b842c6799344531d7ea2969daChris Wren * .build(); 716f021758934b35e3b842c6799344531d7ea2969daChris Wren * </pre> 717f021758934b35e3b842c6799344531d7ea2969daChris Wren * 718f021758934b35e3b842c6799344531d7ea2969daChris Wren * @see Notification#bigContentView 719f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 720f021758934b35e3b842c6799344531d7ea2969daChris Wren public static class InboxStyle extends Style { 721f021758934b35e3b842c6799344531d7ea2969daChris Wren ArrayList<CharSequence> mTexts = new ArrayList<CharSequence>(); 722f021758934b35e3b842c6799344531d7ea2969daChris Wren 723f021758934b35e3b842c6799344531d7ea2969daChris Wren public InboxStyle() { 724f021758934b35e3b842c6799344531d7ea2969daChris Wren } 725f021758934b35e3b842c6799344531d7ea2969daChris Wren 726f021758934b35e3b842c6799344531d7ea2969daChris Wren public InboxStyle(Builder builder) { 727f021758934b35e3b842c6799344531d7ea2969daChris Wren setBuilder(builder); 728f021758934b35e3b842c6799344531d7ea2969daChris Wren } 729f021758934b35e3b842c6799344531d7ea2969daChris Wren 730f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 731f021758934b35e3b842c6799344531d7ea2969daChris Wren * Overrides ContentTitle in the big form of the template. 732f021758934b35e3b842c6799344531d7ea2969daChris Wren * This defaults to the value passed to setContentTitle(). 733f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 734f021758934b35e3b842c6799344531d7ea2969daChris Wren public InboxStyle setBigContentTitle(CharSequence title) { 735f021758934b35e3b842c6799344531d7ea2969daChris Wren mBigContentTitle = title; 736f021758934b35e3b842c6799344531d7ea2969daChris Wren return this; 737f021758934b35e3b842c6799344531d7ea2969daChris Wren } 738f021758934b35e3b842c6799344531d7ea2969daChris Wren 739f021758934b35e3b842c6799344531d7ea2969daChris Wren /** 740f021758934b35e3b842c6799344531d7ea2969daChris Wren * Set the first line of text after the detail section in the big form of the template. 741f021758934b35e3b842c6799344531d7ea2969daChris Wren */ 742f021758934b35e3b842c6799344531d7ea2969daChris Wren public InboxStyle setSummaryText(CharSequence cs) { 743f021758934b35e3b842c6799344531d7ea2969daChris Wren mSummaryText = cs; 744f021758934b35e3b842c6799344531d7ea2969daChris Wren mSummaryTextSet = true; 745f021758934b35e3b842c6799344531d7ea2969daChris Wren return this; 746f021758934b35e3b842c6799344531d7ea2969daChris Wren } 747f021758934b35e3b842c6799344531d7ea2969daChris Wren 748b41a213761ff07de2fcfdaf16790fdcca1a1ee1bChris Wren /** 749b41a213761ff07de2fcfdaf16790fdcca1a1ee1bChris Wren * Append a line to the digest section of the Inbox notification. 750b41a213761ff07de2fcfdaf16790fdcca1a1ee1bChris Wren */ 751f021758934b35e3b842c6799344531d7ea2969daChris Wren public InboxStyle addLine(CharSequence cs) { 752f021758934b35e3b842c6799344531d7ea2969daChris Wren mTexts.add(cs); 753f021758934b35e3b842c6799344531d7ea2969daChris Wren return this; 754f021758934b35e3b842c6799344531d7ea2969daChris Wren } 755f021758934b35e3b842c6799344531d7ea2969daChris Wren } 756f021758934b35e3b842c6799344531d7ea2969daChris Wren 757f021758934b35e3b842c6799344531d7ea2969daChris Wren public static class Action { 758f021758934b35e3b842c6799344531d7ea2969daChris Wren public int icon; 759f021758934b35e3b842c6799344531d7ea2969daChris Wren public CharSequence title; 760f021758934b35e3b842c6799344531d7ea2969daChris Wren public PendingIntent actionIntent; 761f021758934b35e3b842c6799344531d7ea2969daChris Wren 762f021758934b35e3b842c6799344531d7ea2969daChris Wren public Action(int icon_, CharSequence title_, PendingIntent intent_) { 763f021758934b35e3b842c6799344531d7ea2969daChris Wren this.icon = icon_; 764f021758934b35e3b842c6799344531d7ea2969daChris Wren this.title = title_; 765f021758934b35e3b842c6799344531d7ea2969daChris Wren this.actionIntent = intent_; 766c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 767c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell } 768c9cf2eb0a9b6694d0fda3dbc313844955db60820Adam Powell} 769