blob: 3ced82bdfd02244cb691089a5380da8bbbabc402 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.app;
18
Andy Stadler110988c2010-12-03 14:29:16 -080019import com.android.internal.R;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080020
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.content.Context;
22import android.content.Intent;
Daniel Sandler9f7936a2012-05-21 16:14:28 -040023import android.content.res.Resources;
Joe Onoratoef1e7762010-09-17 18:38:38 -040024import android.graphics.Bitmap;
Jeff Sharkey098d5802012-04-26 17:30:34 -070025import android.media.AudioManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026import android.net.Uri;
Daniel Sandler2561b0b2012-02-13 21:04:12 -050027import android.os.Bundle;
Daniel Sandlera0a938c2012-03-15 08:42:37 -040028import android.os.IBinder;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029import android.os.Parcel;
30import android.os.Parcelable;
Daniel Sandlera2985ed2012-04-03 16:42:00 -040031import android.os.SystemClock;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032import android.text.TextUtils;
Daniel Sandlera0a938c2012-03-15 08:42:37 -040033import android.util.IntProperty;
Daniel Sandler96fd7c12012-03-30 16:37:36 -040034import android.util.Log;
Daniel Sandler9f7936a2012-05-21 16:14:28 -040035import android.util.Slog;
36import android.util.TypedValue;
Joe Onorato8595a3d2010-11-19 18:12:07 -080037import android.view.View;
Jeff Sharkey1c400132011-08-05 14:50:13 -070038import android.widget.ProgressBar;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039import android.widget.RemoteViews;
40
Andy Stadler110988c2010-12-03 14:29:16 -080041import java.text.NumberFormat;
Daniel Sandler2561b0b2012-02-13 21:04:12 -050042import java.util.ArrayList;
Joe Onorato561d3852010-11-20 18:09:34 -080043
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044/**
45 * A class that represents how a persistent notification is to be presented to
46 * the user using the {@link android.app.NotificationManager}.
47 *
Joe Onoratocb109a02011-01-18 17:57:41 -080048 * <p>The {@link Notification.Builder Notification.Builder} has been added to make it
49 * easier to construct Notifications.</p>
50 *
Joe Fernandez558459f2011-10-13 16:47:36 -070051 * <div class="special reference">
52 * <h3>Developer Guides</h3>
53 * <p>For a guide to creating notifications, read the
54 * <a href="{@docRoot}guide/topics/ui/notifiers/notifications.html">Status Bar Notifications</a>
55 * developer guide.</p>
56 * </div>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080057 */
58public class Notification implements Parcelable
59{
60 /**
61 * Use all default values (where applicable).
62 */
63 public static final int DEFAULT_ALL = ~0;
Daniel Sandler2561b0b2012-02-13 21:04:12 -050064
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080065 /**
66 * Use the default notification sound. This will ignore any given
67 * {@link #sound}.
Daniel Sandler2561b0b2012-02-13 21:04:12 -050068 *
69
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080070 * @see #defaults
Daniel Sandler2561b0b2012-02-13 21:04:12 -050071 */
72
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080073 public static final int DEFAULT_SOUND = 1;
74
75 /**
76 * Use the default notification vibrate. This will ignore any given
Daniel Sandler2561b0b2012-02-13 21:04:12 -050077 * {@link #vibrate}. Using phone vibration requires the
Scott Mainb8b36452009-04-26 15:50:49 -070078 * {@link android.Manifest.permission#VIBRATE VIBRATE} permission.
Daniel Sandler2561b0b2012-02-13 21:04:12 -050079 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080080 * @see #defaults
Daniel Sandler2561b0b2012-02-13 21:04:12 -050081 */
82
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080083 public static final int DEFAULT_VIBRATE = 2;
Daniel Sandler2561b0b2012-02-13 21:04:12 -050084
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080085 /**
86 * Use the default notification lights. This will ignore the
87 * {@link #FLAG_SHOW_LIGHTS} bit, and {@link #ledARGB}, {@link #ledOffMS}, or
88 * {@link #ledOnMS}.
Daniel Sandler2561b0b2012-02-13 21:04:12 -050089 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080090 * @see #defaults
Daniel Sandler2561b0b2012-02-13 21:04:12 -050091 */
92
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080093 public static final int DEFAULT_LIGHTS = 4;
Daniel Sandler2561b0b2012-02-13 21:04:12 -050094
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080095 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -050096 * A timestamp related to this notification, in milliseconds since the epoch.
97 *
98 * Default value: {@link System#currentTimeMillis() Now}.
99 *
100 * Choose a timestamp that will be most relevant to the user. For most finite events, this
101 * corresponds to the time the event happened (or will happen, in the case of events that have
102 * yet to occur but about which the user is being informed). Indefinite events should be
103 * timestamped according to when the activity began.
104 *
105 * Some examples:
106 *
107 * <ul>
108 * <li>Notification of a new chat message should be stamped when the message was received.</li>
109 * <li>Notification of an ongoing file download (with a progress bar, for example) should be stamped when the download started.</li>
110 * <li>Notification of a completed file download should be stamped when the download finished.</li>
111 * <li>Notification of an upcoming meeting should be stamped with the time the meeting will begin (that is, in the future).</li>
112 * <li>Notification of an ongoing stopwatch (increasing timer) should be stamped with the watch's start time.
113 * <li>Notification of an ongoing countdown timer should be stamped with the timer's end time.
114 * </ul>
115 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800116 */
117 public long when;
118
119 /**
120 * The resource id of a drawable to use as the icon in the status bar.
Daniel Sandlerd952dae2011-02-07 16:33:36 -0500121 * This is required; notifications with an invalid icon resource will not be shown.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800122 */
123 public int icon;
124
125 /**
Joe Onorato46439ce2010-11-19 13:56:21 -0800126 * If the icon in the status bar is to have more than one level, you can set this. Otherwise,
127 * leave it at its default value of 0.
128 *
129 * @see android.widget.ImageView#setImageLevel
130 * @see android.graphics.drawable#setLevel
131 */
132 public int iconLevel;
133
134 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500135 * The number of events that this notification represents. For example, in a new mail
136 * notification, this could be the number of unread messages.
137 *
138 * The system may or may not use this field to modify the appearance of the notification. For
139 * example, before {@link android.os.Build.VERSION_CODES#HONEYCOMB}, this number was
140 * superimposed over the icon in the status bar. Starting with
141 * {@link android.os.Build.VERSION_CODES#HONEYCOMB}, the template used by
142 * {@link Notification.Builder} has displayed the number in the expanded notification view.
143 *
144 * If the number is 0 or negative, it is never shown.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800145 */
146 public int number;
147
148 /**
149 * The intent to execute when the expanded status entry is clicked. If
150 * this is an activity, it must include the
151 * {@link android.content.Intent#FLAG_ACTIVITY_NEW_TASK} flag, which requires
Scott Main7aee61f2011-02-08 11:25:01 -0800152 * that you take care of task management as described in the
153 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
Dianne Hackborn6ceca582012-01-10 15:24:26 -0800154 * Stack</a> document. In particular, make sure to read the notification section
155 * <a href="{@docRoot}guide/topics/ui/notifiers/notifications.html#HandlingNotifications">Handling
156 * Notifications</a> for the correct ways to launch an application from a
157 * notification.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800158 */
159 public PendingIntent contentIntent;
160
161 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500162 * The intent to execute when the notification is explicitly dismissed by the user, either with
163 * the "Clear All" button or by swiping it away individually.
164 *
165 * This probably shouldn't be launching an activity since several of those will be sent
166 * at the same time.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800167 */
168 public PendingIntent deleteIntent;
169
170 /**
Dianne Hackborn170bae72010-09-03 15:14:28 -0700171 * An intent to launch instead of posting the notification to the status bar.
Joe Onoratocb109a02011-01-18 17:57:41 -0800172 *
173 * @see Notification.Builder#setFullScreenIntent
Daniel Sandlere46cbd32010-06-17 10:35:26 -0400174 */
175 public PendingIntent fullScreenIntent;
176
177 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800178 * Text to scroll across the screen when this item is added to
Joe Onoratoef1e7762010-09-17 18:38:38 -0400179 * the status bar on large and smaller devices.
180 *
Joe Onorato46439ce2010-11-19 13:56:21 -0800181 * @see #tickerView
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800182 */
183 public CharSequence tickerText;
184
185 /**
Joe Onorato46439ce2010-11-19 13:56:21 -0800186 * The view to show as the ticker in the status bar when the notification
187 * is posted.
Joe Onoratoef1e7762010-09-17 18:38:38 -0400188 */
Joe Onorato46439ce2010-11-19 13:56:21 -0800189 public RemoteViews tickerView;
Joe Onoratoef1e7762010-09-17 18:38:38 -0400190
191 /**
Daniel Sandlere46cbd32010-06-17 10:35:26 -0400192 * The view that will represent this notification in the expanded status bar.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800193 */
194 public RemoteViews contentView;
195
Daniel Sandlera0a938c2012-03-15 08:42:37 -0400196 /**
Daniel Sandler4dfbe832012-04-11 14:51:46 -0400197 * A large-format version of {@link #contentView}, giving the Notification an
Daniel Sandlerf3b73432012-03-27 15:01:25 -0400198 * opportunity to show more detail. The system UI may choose to show this
199 * instead of the normal content view at its discretion.
Daniel Sandlerf3b73432012-03-27 15:01:25 -0400200 */
201 public RemoteViews bigContentView;
202
203 /**
Joe Onorato46439ce2010-11-19 13:56:21 -0800204 * The bitmap that may escape the bounds of the panel and bar.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800205 */
Joe Onorato46439ce2010-11-19 13:56:21 -0800206 public Bitmap largeIcon;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800207
208 /**
209 * The sound to play.
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500210 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800211 * <p>
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500212 * To play the default notification sound, see {@link #defaults}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800213 * </p>
214 */
215 public Uri sound;
216
217 /**
218 * Use this constant as the value for audioStreamType to request that
219 * the default stream type for notifications be used. Currently the
Jeff Sharkey098d5802012-04-26 17:30:34 -0700220 * default stream type is {@link AudioManager#STREAM_NOTIFICATION}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800221 */
222 public static final int STREAM_DEFAULT = -1;
223
224 /**
225 * The audio stream type to use when playing the sound.
226 * Should be one of the STREAM_ constants from
227 * {@link android.media.AudioManager}.
228 */
229 public int audioStreamType = STREAM_DEFAULT;
230
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800231 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500232 * The pattern with which to vibrate.
233 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800234 * <p>
235 * To vibrate the default pattern, see {@link #defaults}.
236 * </p>
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500237 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800238 * @see android.os.Vibrator#vibrate(long[],int)
239 */
240 public long[] vibrate;
241
242 /**
243 * The color of the led. The hardware will do its best approximation.
244 *
245 * @see #FLAG_SHOW_LIGHTS
246 * @see #flags
247 */
248 public int ledARGB;
249
250 /**
251 * The number of milliseconds for the LED to be on while it's flashing.
252 * The hardware will do its best approximation.
253 *
254 * @see #FLAG_SHOW_LIGHTS
255 * @see #flags
256 */
257 public int ledOnMS;
258
259 /**
260 * The number of milliseconds for the LED to be off while it's flashing.
261 * The hardware will do its best approximation.
262 *
263 * @see #FLAG_SHOW_LIGHTS
264 * @see #flags
265 */
266 public int ledOffMS;
267
268 /**
269 * Specifies which values should be taken from the defaults.
270 * <p>
271 * To set, OR the desired from {@link #DEFAULT_SOUND},
272 * {@link #DEFAULT_VIBRATE}, {@link #DEFAULT_LIGHTS}. For all default
273 * values, use {@link #DEFAULT_ALL}.
274 * </p>
275 */
276 public int defaults;
277
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800278 /**
279 * Bit to be bitwise-ored into the {@link #flags} field that should be
280 * set if you want the LED on for this notification.
281 * <ul>
282 * <li>To turn the LED off, pass 0 in the alpha channel for colorARGB
283 * or 0 for both ledOnMS and ledOffMS.</li>
284 * <li>To turn the LED on, pass 1 for ledOnMS and 0 for ledOffMS.</li>
285 * <li>To flash the LED, pass the number of milliseconds that it should
286 * be on and off to ledOnMS and ledOffMS.</li>
287 * </ul>
288 * <p>
289 * Since hardware varies, you are not guaranteed that any of the values
290 * you pass are honored exactly. Use the system defaults (TODO) if possible
291 * because they will be set to values that work on any given hardware.
292 * <p>
293 * The alpha channel must be set for forward compatibility.
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500294 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800295 */
296 public static final int FLAG_SHOW_LIGHTS = 0x00000001;
297
298 /**
299 * Bit to be bitwise-ored into the {@link #flags} field that should be
300 * set if this notification is in reference to something that is ongoing,
301 * like a phone call. It should not be set if this notification is in
302 * reference to something that happened at a particular point in time,
303 * like a missed phone call.
304 */
305 public static final int FLAG_ONGOING_EVENT = 0x00000002;
306
307 /**
308 * Bit to be bitwise-ored into the {@link #flags} field that if set,
Scott Mainb8b36452009-04-26 15:50:49 -0700309 * the audio will be repeated until the notification is
310 * cancelled or the notification window is opened.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800311 */
312 public static final int FLAG_INSISTENT = 0x00000004;
313
314 /**
315 * Bit to be bitwise-ored into the {@link #flags} field that should be
316 * set if you want the sound and/or vibration play each time the
317 * notification is sent, even if it has not been canceled before that.
318 */
319 public static final int FLAG_ONLY_ALERT_ONCE = 0x00000008;
320
321 /**
322 * Bit to be bitwise-ored into the {@link #flags} field that should be
323 * set if the notification should be canceled when it is clicked by the
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500324 * user. On tablets, the
325
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800326 */
327 public static final int FLAG_AUTO_CANCEL = 0x00000010;
328
329 /**
330 * Bit to be bitwise-ored into the {@link #flags} field that should be
331 * set if the notification should not be canceled when the user clicks
332 * the Clear all button.
333 */
334 public static final int FLAG_NO_CLEAR = 0x00000020;
335
Dianne Hackbornd8a43f62009-08-17 23:33:56 -0700336 /**
337 * Bit to be bitwise-ored into the {@link #flags} field that should be
338 * set if this notification represents a currently running service. This
339 * will normally be set for you by {@link Service#startForeground}.
340 */
341 public static final int FLAG_FOREGROUND_SERVICE = 0x00000040;
342
Daniel Sandlere46cbd32010-06-17 10:35:26 -0400343 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500344 * Obsolete flag indicating high-priority notifications; use the priority field instead.
345 *
346 * @deprecated Use {@link #priority} with a positive value.
Daniel Sandlere46cbd32010-06-17 10:35:26 -0400347 */
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500348 public static final int FLAG_HIGH_PRIORITY = 0x00000080;
Daniel Sandlere46cbd32010-06-17 10:35:26 -0400349
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800350 public int flags;
351
352 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500353 * Default notification {@link #priority}. If your application does not prioritize its own
354 * notifications, use this value for all notifications.
355 */
356 public static final int PRIORITY_DEFAULT = 0;
357
358 /**
359 * Lower {@link #priority}, for items that are less important. The UI may choose to show these
360 * items smaller, or at a different position in the list, compared with your app's
361 * {@link #PRIORITY_DEFAULT} items.
362 */
363 public static final int PRIORITY_LOW = -1;
364
365 /**
366 * Lowest {@link #priority}; these items might not be shown to the user except under special
367 * circumstances, such as detailed notification logs.
368 */
369 public static final int PRIORITY_MIN = -2;
370
371 /**
372 * Higher {@link #priority}, for more important notifications or alerts. The UI may choose to
373 * show these items larger, or at a different position in notification lists, compared with
374 * your app's {@link #PRIORITY_DEFAULT} items.
375 */
376 public static final int PRIORITY_HIGH = 1;
377
378 /**
379 * Highest {@link #priority}, for your application's most important items that require the
380 * user's prompt attention or input.
381 */
382 public static final int PRIORITY_MAX = 2;
383
384 /**
385 * Relative priority for this notification.
386 *
387 * Priority is an indication of how much of the user's valuable attention should be consumed by
388 * this notification. Low-priority notifications may be hidden from the user in certain
389 * situations, while the user might be interrupted for a higher-priority notification. The
390 * system will make a determination about how to interpret notification priority as described in
391 * MUMBLE MUMBLE.
392 */
393 public int priority;
394
395 /**
Daniel Sandlerd33b8032012-05-10 11:41:48 -0400396 * @hide
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500397 * Notification type: incoming call (voice or video) or similar synchronous communication request.
398 */
399 public static final String KIND_CALL = "android.call";
400
401 /**
Daniel Sandlerd33b8032012-05-10 11:41:48 -0400402 * @hide
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500403 * Notification type: incoming direct message (SMS, instant message, etc.).
404 */
405 public static final String KIND_MESSAGE = "android.message";
406
407 /**
Daniel Sandlerd33b8032012-05-10 11:41:48 -0400408 * @hide
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500409 * Notification type: asynchronous bulk message (email).
410 */
411 public static final String KIND_EMAIL = "android.email";
412
413 /**
Daniel Sandlerd33b8032012-05-10 11:41:48 -0400414 * @hide
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500415 * Notification type: calendar event.
416 */
417 public static final String KIND_EVENT = "android.event";
418
419 /**
420 * Notification type: promotion or advertisement.
421 */
422 public static final String KIND_PROMO = "android.promo";
423
424 /**
Daniel Sandlerd33b8032012-05-10 11:41:48 -0400425 * @hide
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500426 * If this notification matches of one or more special types (see the <code>KIND_*</code>
427 * constants), add them here, best match first.
428 */
429 public String[] kind;
430
431 /**
432 * Extra key for people values (type TBD).
433 *
434 * @hide
435 */
436 public static final String EXTRA_PEOPLE = "android.people";
437
438 private Bundle extras;
439
440 /**
Daniel Sandlera0a938c2012-03-15 08:42:37 -0400441 * Structure to encapsulate an "action", including title and icon, that can be attached to a Notification.
442 * @hide
443 */
444 private static class Action implements Parcelable {
445 public int icon;
446 public CharSequence title;
447 public PendingIntent actionIntent;
448 @SuppressWarnings("unused")
449 public Action() { }
450 private Action(Parcel in) {
451 icon = in.readInt();
452 title = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
453 if (in.readInt() == 1) {
454 actionIntent = PendingIntent.CREATOR.createFromParcel(in);
455 }
456 }
457 public Action(int icon_, CharSequence title_, PendingIntent intent_) {
458 this.icon = icon_;
459 this.title = title_;
460 this.actionIntent = intent_;
461 }
462 @Override
463 public Action clone() {
464 return new Action(
465 this.icon,
466 this.title.toString(),
467 this.actionIntent // safe to alias
468 );
469 }
470 @Override
471 public int describeContents() {
472 return 0;
473 }
474 @Override
475 public void writeToParcel(Parcel out, int flags) {
476 out.writeInt(icon);
477 TextUtils.writeToParcel(title, out, flags);
478 if (actionIntent != null) {
479 out.writeInt(1);
480 actionIntent.writeToParcel(out, flags);
481 } else {
482 out.writeInt(0);
483 }
484 }
485 public static final Parcelable.Creator<Action> CREATOR
486 = new Parcelable.Creator<Action>() {
487 public Action createFromParcel(Parcel in) {
488 return new Action(in);
489 }
490 public Action[] newArray(int size) {
491 return new Action[size];
492 }
493 };
494 }
495
496 private Action[] actions;
497
498 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500499 * Constructs a Notification object with default values.
Joe Onorato46439ce2010-11-19 13:56:21 -0800500 * You might want to consider using {@link Builder} instead.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800501 */
502 public Notification()
503 {
504 this.when = System.currentTimeMillis();
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500505 this.priority = PRIORITY_DEFAULT;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800506 }
507
508 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800509 * @hide
510 */
511 public Notification(Context context, int icon, CharSequence tickerText, long when,
512 CharSequence contentTitle, CharSequence contentText, Intent contentIntent)
513 {
514 this.when = when;
515 this.icon = icon;
516 this.tickerText = tickerText;
517 setLatestEventInfo(context, contentTitle, contentText,
518 PendingIntent.getActivity(context, 0, contentIntent, 0));
519 }
520
521 /**
522 * Constructs a Notification object with the information needed to
523 * have a status bar icon without the standard expanded view.
524 *
525 * @param icon The resource id of the icon to put in the status bar.
526 * @param tickerText The text that flows by in the status bar when the notification first
527 * activates.
528 * @param when The time to show in the time field. In the System.currentTimeMillis
529 * timebase.
Joe Onorato46439ce2010-11-19 13:56:21 -0800530 *
531 * @deprecated Use {@link Builder} instead.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800532 */
Joe Onorato46439ce2010-11-19 13:56:21 -0800533 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800534 public Notification(int icon, CharSequence tickerText, long when)
535 {
536 this.icon = icon;
537 this.tickerText = tickerText;
538 this.when = when;
539 }
540
541 /**
542 * Unflatten the notification from a parcel.
543 */
544 public Notification(Parcel parcel)
545 {
546 int version = parcel.readInt();
547
548 when = parcel.readLong();
549 icon = parcel.readInt();
550 number = parcel.readInt();
551 if (parcel.readInt() != 0) {
552 contentIntent = PendingIntent.CREATOR.createFromParcel(parcel);
553 }
554 if (parcel.readInt() != 0) {
555 deleteIntent = PendingIntent.CREATOR.createFromParcel(parcel);
556 }
557 if (parcel.readInt() != 0) {
558 tickerText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel);
559 }
560 if (parcel.readInt() != 0) {
Joe Onorato46439ce2010-11-19 13:56:21 -0800561 tickerView = RemoteViews.CREATOR.createFromParcel(parcel);
Joe Onoratoef1e7762010-09-17 18:38:38 -0400562 }
563 if (parcel.readInt() != 0) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800564 contentView = RemoteViews.CREATOR.createFromParcel(parcel);
565 }
Joe Onorato561d3852010-11-20 18:09:34 -0800566 if (parcel.readInt() != 0) {
567 largeIcon = Bitmap.CREATOR.createFromParcel(parcel);
568 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800569 defaults = parcel.readInt();
570 flags = parcel.readInt();
571 if (parcel.readInt() != 0) {
572 sound = Uri.CREATOR.createFromParcel(parcel);
573 }
574
575 audioStreamType = parcel.readInt();
576 vibrate = parcel.createLongArray();
577 ledARGB = parcel.readInt();
578 ledOnMS = parcel.readInt();
579 ledOffMS = parcel.readInt();
580 iconLevel = parcel.readInt();
Daniel Sandlere46cbd32010-06-17 10:35:26 -0400581
582 if (parcel.readInt() != 0) {
583 fullScreenIntent = PendingIntent.CREATOR.createFromParcel(parcel);
584 }
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500585
586 priority = parcel.readInt();
Daniel Sandlera0a938c2012-03-15 08:42:37 -0400587
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500588 kind = parcel.createStringArray(); // may set kind to null
589
590 if (parcel.readInt() != 0) {
591 extras = parcel.readBundle();
592 }
Daniel Sandlera0a938c2012-03-15 08:42:37 -0400593
594 actions = parcel.createTypedArray(Action.CREATOR);
595 if (parcel.readInt() != 0) {
Daniel Sandlerf3b73432012-03-27 15:01:25 -0400596 bigContentView = RemoteViews.CREATOR.createFromParcel(parcel);
597 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800598 }
599
Andy Stadler110988c2010-12-03 14:29:16 -0800600 @Override
Joe Onorato18e69df2010-05-17 22:26:12 -0700601 public Notification clone() {
602 Notification that = new Notification();
603
604 that.when = this.when;
605 that.icon = this.icon;
606 that.number = this.number;
607
608 // PendingIntents are global, so there's no reason (or way) to clone them.
609 that.contentIntent = this.contentIntent;
610 that.deleteIntent = this.deleteIntent;
Daniel Sandlere46cbd32010-06-17 10:35:26 -0400611 that.fullScreenIntent = this.fullScreenIntent;
Joe Onorato18e69df2010-05-17 22:26:12 -0700612
613 if (this.tickerText != null) {
614 that.tickerText = this.tickerText.toString();
615 }
Joe Onorato46439ce2010-11-19 13:56:21 -0800616 if (this.tickerView != null) {
617 that.tickerView = this.tickerView.clone();
Joe Onoratoef1e7762010-09-17 18:38:38 -0400618 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700619 if (this.contentView != null) {
620 that.contentView = this.contentView.clone();
621 }
Joe Onorato561d3852010-11-20 18:09:34 -0800622 if (this.largeIcon != null) {
623 that.largeIcon = Bitmap.createBitmap(this.largeIcon);
624 }
Jozef BABJAKa8b91832011-02-22 08:05:08 +0100625 that.iconLevel = this.iconLevel;
Joe Onorato18e69df2010-05-17 22:26:12 -0700626 that.sound = this.sound; // android.net.Uri is immutable
627 that.audioStreamType = this.audioStreamType;
628
629 final long[] vibrate = this.vibrate;
630 if (vibrate != null) {
631 final int N = vibrate.length;
632 final long[] vib = that.vibrate = new long[N];
633 System.arraycopy(vibrate, 0, vib, 0, N);
634 }
635
636 that.ledARGB = this.ledARGB;
637 that.ledOnMS = this.ledOnMS;
638 that.ledOffMS = this.ledOffMS;
639 that.defaults = this.defaults;
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500640
Joe Onorato18e69df2010-05-17 22:26:12 -0700641 that.flags = this.flags;
642
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500643 that.priority = this.priority;
644
645 final String[] thiskind = this.kind;
646 if (thiskind != null) {
647 final int N = thiskind.length;
648 final String[] thatkind = that.kind = new String[N];
649 System.arraycopy(thiskind, 0, thatkind, 0, N);
650 }
651
652 if (this.extras != null) {
653 that.extras = new Bundle(this.extras);
654
655 }
656
Daniel Sandlera0a938c2012-03-15 08:42:37 -0400657 that.actions = new Action[this.actions.length];
658 for(int i=0; i<this.actions.length; i++) {
659 that.actions[i] = this.actions[i].clone();
660 }
Daniel Sandlerf3b73432012-03-27 15:01:25 -0400661 if (this.bigContentView != null) {
662 that.bigContentView = this.bigContentView.clone();
663 }
Daniel Sandlera0a938c2012-03-15 08:42:37 -0400664
Joe Onorato18e69df2010-05-17 22:26:12 -0700665 return that;
666 }
667
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800668 public int describeContents() {
669 return 0;
670 }
671
672 /**
673 * Flatten this notification from a parcel.
674 */
675 public void writeToParcel(Parcel parcel, int flags)
676 {
677 parcel.writeInt(1);
678
679 parcel.writeLong(when);
680 parcel.writeInt(icon);
681 parcel.writeInt(number);
682 if (contentIntent != null) {
683 parcel.writeInt(1);
684 contentIntent.writeToParcel(parcel, 0);
685 } else {
686 parcel.writeInt(0);
687 }
688 if (deleteIntent != null) {
689 parcel.writeInt(1);
690 deleteIntent.writeToParcel(parcel, 0);
691 } else {
692 parcel.writeInt(0);
693 }
694 if (tickerText != null) {
695 parcel.writeInt(1);
696 TextUtils.writeToParcel(tickerText, parcel, flags);
697 } else {
698 parcel.writeInt(0);
699 }
Joe Onorato46439ce2010-11-19 13:56:21 -0800700 if (tickerView != null) {
Joe Onoratoef1e7762010-09-17 18:38:38 -0400701 parcel.writeInt(1);
Joe Onorato46439ce2010-11-19 13:56:21 -0800702 tickerView.writeToParcel(parcel, 0);
Joe Onoratoef1e7762010-09-17 18:38:38 -0400703 } else {
704 parcel.writeInt(0);
705 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800706 if (contentView != null) {
707 parcel.writeInt(1);
708 contentView.writeToParcel(parcel, 0);
709 } else {
710 parcel.writeInt(0);
711 }
Joe Onorato561d3852010-11-20 18:09:34 -0800712 if (largeIcon != null) {
713 parcel.writeInt(1);
714 largeIcon.writeToParcel(parcel, 0);
715 } else {
716 parcel.writeInt(0);
717 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800718
719 parcel.writeInt(defaults);
720 parcel.writeInt(this.flags);
721
722 if (sound != null) {
723 parcel.writeInt(1);
724 sound.writeToParcel(parcel, 0);
725 } else {
726 parcel.writeInt(0);
727 }
728 parcel.writeInt(audioStreamType);
729 parcel.writeLongArray(vibrate);
730 parcel.writeInt(ledARGB);
731 parcel.writeInt(ledOnMS);
732 parcel.writeInt(ledOffMS);
733 parcel.writeInt(iconLevel);
Daniel Sandlere46cbd32010-06-17 10:35:26 -0400734
735 if (fullScreenIntent != null) {
736 parcel.writeInt(1);
737 fullScreenIntent.writeToParcel(parcel, 0);
738 } else {
739 parcel.writeInt(0);
740 }
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500741
742 parcel.writeInt(priority);
743
744 parcel.writeStringArray(kind); // ok for null
745
746 if (extras != null) {
747 parcel.writeInt(1);
748 extras.writeToParcel(parcel, 0);
749 } else {
750 parcel.writeInt(0);
751 }
Daniel Sandlera0a938c2012-03-15 08:42:37 -0400752
753 parcel.writeTypedArray(actions, 0);
754
Daniel Sandlerf3b73432012-03-27 15:01:25 -0400755 if (bigContentView != null) {
756 parcel.writeInt(1);
757 bigContentView.writeToParcel(parcel, 0);
758 } else {
759 parcel.writeInt(0);
760 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800761 }
762
763 /**
764 * Parcelable.Creator that instantiates Notification objects
765 */
766 public static final Parcelable.Creator<Notification> CREATOR
767 = new Parcelable.Creator<Notification>()
768 {
769 public Notification createFromParcel(Parcel parcel)
770 {
771 return new Notification(parcel);
772 }
773
774 public Notification[] newArray(int size)
775 {
776 return new Notification[size];
777 }
778 };
779
780 /**
781 * Sets the {@link #contentView} field to be a view with the standard "Latest Event"
782 * layout.
783 *
784 * <p>Uses the {@link #icon} and {@link #when} fields to set the icon and time fields
785 * in the view.</p>
786 * @param context The context for your application / activity.
787 * @param contentTitle The title that goes in the expanded entry.
788 * @param contentText The text that goes in the expanded entry.
789 * @param contentIntent The intent to launch when the user clicks the expanded notification.
790 * If this is an activity, it must include the
791 * {@link android.content.Intent#FLAG_ACTIVITY_NEW_TASK} flag, which requires
Scott Main7aee61f2011-02-08 11:25:01 -0800792 * that you take care of task management as described in the
793 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
794 * Stack</a> document.
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500795 *
Joe Onorato46439ce2010-11-19 13:56:21 -0800796 * @deprecated Use {@link Builder} instead.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800797 */
Joe Onorato46439ce2010-11-19 13:56:21 -0800798 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800799 public void setLatestEventInfo(Context context,
800 CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent) {
Daniel Sandlercde8aae2012-04-04 23:40:22 -0400801 // TODO: rewrite this to use Builder
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800802 RemoteViews contentView = new RemoteViews(context.getPackageName(),
Daniel Sandler96fd7c12012-03-30 16:37:36 -0400803 R.layout.notification_template_base);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800804 if (this.icon != 0) {
Joe Onorato561d3852010-11-20 18:09:34 -0800805 contentView.setImageViewResource(R.id.icon, this.icon);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800806 }
Daniel Sandlere95658c2012-05-10 00:33:54 -0400807 if (priority < PRIORITY_LOW) {
808 contentView.setInt(R.id.icon,
809 "setBackgroundResource", R.drawable.notification_template_icon_low_bg);
810 contentView.setInt(R.id.status_bar_latest_event_content,
811 "setBackgroundResource", R.drawable.notification_bg_low);
812 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800813 if (contentTitle != null) {
Joe Onorato561d3852010-11-20 18:09:34 -0800814 contentView.setTextViewText(R.id.title, contentTitle);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800815 }
816 if (contentText != null) {
Joe Onorato561d3852010-11-20 18:09:34 -0800817 contentView.setTextViewText(R.id.text, contentText);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800818 }
819 if (this.when != 0) {
Daniel Sandlercde8aae2012-04-04 23:40:22 -0400820 contentView.setViewVisibility(R.id.time, View.VISIBLE);
Joe Onorato561d3852010-11-20 18:09:34 -0800821 contentView.setLong(R.id.time, "setTime", when);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800822 }
Daniel Sandlerb4b22232012-04-30 10:38:31 -0400823 if (this.number != 0) {
824 NumberFormat f = NumberFormat.getIntegerInstance();
825 contentView.setTextViewText(R.id.info, f.format(this.number));
826 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800827
828 this.contentView = contentView;
829 this.contentIntent = contentIntent;
830 }
831
832 @Override
833 public String toString() {
834 StringBuilder sb = new StringBuilder();
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500835 sb.append("Notification(pri=");
836 sb.append(priority);
837 sb.append(" contentView=");
Joe Onoratoc9596d62011-01-12 17:03:11 -0800838 if (contentView != null) {
839 sb.append(contentView.getPackage());
840 sb.append("/0x");
841 sb.append(Integer.toHexString(contentView.getLayoutId()));
842 } else {
843 sb.append("null");
844 }
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500845 // TODO(dsandler): defaults take precedence over local values, so reorder the branches below
Joe Onoratoc9596d62011-01-12 17:03:11 -0800846 sb.append(" vibrate=");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800847 if (this.vibrate != null) {
848 int N = this.vibrate.length-1;
849 sb.append("[");
850 for (int i=0; i<N; i++) {
851 sb.append(this.vibrate[i]);
852 sb.append(',');
853 }
Simon Schoar8cf97d92009-06-10 22:08:37 +0200854 if (N != -1) {
855 sb.append(this.vibrate[N]);
856 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800857 sb.append("]");
858 } else if ((this.defaults & DEFAULT_VIBRATE) != 0) {
859 sb.append("default");
860 } else {
861 sb.append("null");
862 }
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500863 sb.append(" sound=");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800864 if (this.sound != null) {
865 sb.append(this.sound.toString());
866 } else if ((this.defaults & DEFAULT_SOUND) != 0) {
867 sb.append("default");
868 } else {
869 sb.append("null");
870 }
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500871 sb.append(" defaults=0x");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800872 sb.append(Integer.toHexString(this.defaults));
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500873 sb.append(" flags=0x");
Daniel Sandlere46cbd32010-06-17 10:35:26 -0400874 sb.append(Integer.toHexString(this.flags));
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500875 sb.append(" kind=[");
876 if (this.kind == null) {
877 sb.append("null");
878 } else {
879 for (int i=0; i<this.kind.length; i++) {
880 if (i>0) sb.append(",");
881 sb.append(this.kind[i]);
882 }
Daniel Sandlere46cbd32010-06-17 10:35:26 -0400883 }
Daniel Sandlera0a938c2012-03-15 08:42:37 -0400884 sb.append("]");
885 if (actions != null) {
886 sb.append(" ");
887 sb.append(actions.length);
888 sb.append(" action");
889 if (actions.length > 1) sb.append("s");
890 }
891 sb.append(")");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800892 return sb.toString();
893 }
Joe Onorato46439ce2010-11-19 13:56:21 -0800894
Joe Onoratocb109a02011-01-18 17:57:41 -0800895 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500896 * Builder class for {@link Notification} objects.
897 *
898 * Provides a convenient way to set the various fields of a {@link Notification} and generate
899 * content views using the platform's notification layout template.
900 *
901 * Example:
902 *
903 * <pre class="prettyprint">
904 * Notification noti = new Notification.Builder()
905 * .setContentTitle(&quot;New mail from &quot; + sender.toString())
906 * .setContentText(subject)
907 * .setSmallIcon(R.drawable.new_mail)
908 * .setLargeIcon(aBitmap)
Chris Wrenfbd96ba2012-05-01 12:03:58 -0400909 * .build();
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500910 * </pre>
Joe Onoratocb109a02011-01-18 17:57:41 -0800911 */
Joe Onorato46439ce2010-11-19 13:56:21 -0800912 public static class Builder {
Daniel Sandler8680bf82012-05-15 16:52:52 -0400913 private static final int MAX_ACTION_BUTTONS = 2;
914
Joe Onorato46439ce2010-11-19 13:56:21 -0800915 private Context mContext;
916
917 private long mWhen;
918 private int mSmallIcon;
919 private int mSmallIconLevel;
Joe Onorato8595a3d2010-11-19 18:12:07 -0800920 private int mNumber;
Joe Onorato46439ce2010-11-19 13:56:21 -0800921 private CharSequence mContentTitle;
922 private CharSequence mContentText;
923 private CharSequence mContentInfo;
Daniel Sandlerf3b73432012-03-27 15:01:25 -0400924 private CharSequence mSubText;
Joe Onorato46439ce2010-11-19 13:56:21 -0800925 private PendingIntent mContentIntent;
926 private RemoteViews mContentView;
927 private PendingIntent mDeleteIntent;
928 private PendingIntent mFullScreenIntent;
929 private CharSequence mTickerText;
930 private RemoteViews mTickerView;
931 private Bitmap mLargeIcon;
932 private Uri mSound;
933 private int mAudioStreamType;
934 private long[] mVibrate;
935 private int mLedArgb;
936 private int mLedOnMs;
937 private int mLedOffMs;
938 private int mDefaults;
939 private int mFlags;
Jeff Sharkey1c400132011-08-05 14:50:13 -0700940 private int mProgressMax;
941 private int mProgress;
942 private boolean mProgressIndeterminate;
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500943 private ArrayList<String> mKindList = new ArrayList<String>(1);
944 private Bundle mExtras;
945 private int mPriority;
Daniel Sandler8680bf82012-05-15 16:52:52 -0400946 private ArrayList<Action> mActions = new ArrayList<Action>(MAX_ACTION_BUTTONS);
Daniel Sandlera2985ed2012-04-03 16:42:00 -0400947 private boolean mUseChronometer;
Chris Wrenfbd96ba2012-05-01 12:03:58 -0400948 private Style mStyle;
Joe Onorato46439ce2010-11-19 13:56:21 -0800949
Joe Onoratocb109a02011-01-18 17:57:41 -0800950 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500951 * Constructs a new Builder with the defaults:
Joe Onoratocb109a02011-01-18 17:57:41 -0800952 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500953
954 * <table>
955 * <tr><th align=right>priority</th>
956 * <td>{@link #PRIORITY_DEFAULT}</td></tr>
957 * <tr><th align=right>when</th>
958 * <td>now ({@link System#currentTimeMillis()})</td></tr>
959 * <tr><th align=right>audio stream</th>
960 * <td>{@link #STREAM_DEFAULT}</td></tr>
961 * </table>
Joe Onoratocb109a02011-01-18 17:57:41 -0800962 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500963
964 * @param context
965 * A {@link Context} that will be used by the Builder to construct the
966 * RemoteViews. The Context will not be held past the lifetime of this Builder
967 * object.
Joe Onoratocb109a02011-01-18 17:57:41 -0800968 */
Joe Onorato46439ce2010-11-19 13:56:21 -0800969 public Builder(Context context) {
970 mContext = context;
Andy Stadler110988c2010-12-03 14:29:16 -0800971
972 // Set defaults to match the defaults of a Notification
Joe Onorato46439ce2010-11-19 13:56:21 -0800973 mWhen = System.currentTimeMillis();
Andy Stadler110988c2010-12-03 14:29:16 -0800974 mAudioStreamType = STREAM_DEFAULT;
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500975 mPriority = PRIORITY_DEFAULT;
Joe Onorato46439ce2010-11-19 13:56:21 -0800976 }
977
Joe Onoratocb109a02011-01-18 17:57:41 -0800978 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500979 * Add a timestamp pertaining to the notification (usually the time the event occurred).
980 *
981
982 * @see Notification#when
Joe Onoratocb109a02011-01-18 17:57:41 -0800983 */
Joe Onorato46439ce2010-11-19 13:56:21 -0800984 public Builder setWhen(long when) {
985 mWhen = when;
986 return this;
987 }
988
Joe Onoratocb109a02011-01-18 17:57:41 -0800989 /**
Daniel Sandlerd33b8032012-05-10 11:41:48 -0400990 * Show the {@link Notification#when} field as a stopwatch.
991 *
992 * Instead of presenting <code>when</code> as a timestamp, the notification will show an
993 * automatically updating display of the minutes and seconds since <code>when</code>.
Daniel Sandlera2985ed2012-04-03 16:42:00 -0400994 *
Daniel Sandlerd33b8032012-05-10 11:41:48 -0400995 * Useful when showing an elapsed time (like an ongoing phone call).
996 *
997 * @see android.widget.Chronometer
Daniel Sandlera2985ed2012-04-03 16:42:00 -0400998 * @see Notification#when
999 */
1000 public Builder setUsesChronometer(boolean b) {
1001 mUseChronometer = b;
1002 return this;
1003 }
1004
1005 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001006 * Set the small icon resource, which will be used to represent the notification in the
1007 * status bar.
Joe Onoratocb109a02011-01-18 17:57:41 -08001008 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001009
1010 * The platform template for the expanded view will draw this icon in the left, unless a
1011 * {@link #setLargeIcon(Bitmap) large icon} has also been specified, in which case the small
1012 * icon will be moved to the right-hand side.
1013 *
1014
1015 * @param icon
1016 * A resource ID in the application's package of the drawable to use.
1017 * @see Notification#icon
Joe Onoratocb109a02011-01-18 17:57:41 -08001018 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001019 public Builder setSmallIcon(int icon) {
1020 mSmallIcon = icon;
1021 return this;
1022 }
1023
Joe Onoratocb109a02011-01-18 17:57:41 -08001024 /**
1025 * A variant of {@link #setSmallIcon(int) setSmallIcon(int)} that takes an additional
1026 * level parameter for when the icon is a {@link android.graphics.drawable.LevelListDrawable
1027 * LevelListDrawable}.
1028 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001029 * @param icon A resource ID in the application's package of the drawable to use.
Joe Onoratocb109a02011-01-18 17:57:41 -08001030 * @param level The level to use for the icon.
1031 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001032 * @see Notification#icon
1033 * @see Notification#iconLevel
Joe Onoratocb109a02011-01-18 17:57:41 -08001034 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001035 public Builder setSmallIcon(int icon, int level) {
1036 mSmallIcon = icon;
1037 mSmallIconLevel = level;
1038 return this;
1039 }
1040
Joe Onoratocb109a02011-01-18 17:57:41 -08001041 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001042 * Set the first line of text in the platform notification template.
Joe Onoratocb109a02011-01-18 17:57:41 -08001043 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001044 public Builder setContentTitle(CharSequence title) {
1045 mContentTitle = title;
1046 return this;
1047 }
1048
Joe Onoratocb109a02011-01-18 17:57:41 -08001049 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001050 * Set the second line of text in the platform notification template.
Joe Onoratocb109a02011-01-18 17:57:41 -08001051 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001052 public Builder setContentText(CharSequence text) {
1053 mContentText = text;
1054 return this;
1055 }
1056
Joe Onoratocb109a02011-01-18 17:57:41 -08001057 /**
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001058 * Set the third line of text in the platform notification template.
1059 * Don't use if you're also using {@link #setProgress(int, int, boolean)}; they occupy the same location in the standard template.
1060 */
1061 public Builder setSubText(CharSequence text) {
1062 mSubText = text;
1063 return this;
1064 }
1065
1066 /**
Joe Onoratocb109a02011-01-18 17:57:41 -08001067 * Set the large number at the right-hand side of the notification. This is
1068 * equivalent to setContentInfo, although it might show the number in a different
1069 * font size for readability.
1070 */
Joe Onorato8595a3d2010-11-19 18:12:07 -08001071 public Builder setNumber(int number) {
1072 mNumber = number;
1073 return this;
1074 }
1075
Joe Onoratocb109a02011-01-18 17:57:41 -08001076 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001077 * A small piece of additional information pertaining to this notification.
1078 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001079 * The platform template will draw this on the last line of the notification, at the far
1080 * right (to the right of a smallIcon if it has been placed there).
Joe Onoratocb109a02011-01-18 17:57:41 -08001081 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001082 public Builder setContentInfo(CharSequence info) {
1083 mContentInfo = info;
1084 return this;
1085 }
1086
Joe Onoratocb109a02011-01-18 17:57:41 -08001087 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001088 * Set the progress this notification represents.
1089 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001090 * The platform template will represent this using a {@link ProgressBar}.
Jeff Sharkey1c400132011-08-05 14:50:13 -07001091 */
1092 public Builder setProgress(int max, int progress, boolean indeterminate) {
1093 mProgressMax = max;
1094 mProgress = progress;
1095 mProgressIndeterminate = indeterminate;
1096 return this;
1097 }
1098
1099 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001100 * Supply a custom RemoteViews to use instead of the platform template.
1101 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001102 * @see Notification#contentView
Joe Onoratocb109a02011-01-18 17:57:41 -08001103 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001104 public Builder setContent(RemoteViews views) {
1105 mContentView = views;
1106 return this;
1107 }
1108
Joe Onoratocb109a02011-01-18 17:57:41 -08001109 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001110 * Supply a {@link PendingIntent} to be sent when the notification is clicked.
1111 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001112 * As of {@link android.os.Build.VERSION_CODES#HONEYCOMB}, if this field is unset and you
1113 * have specified a custom RemoteViews with {@link #setContent(RemoteViews)}, you can use
1114 * {@link RemoteViews#setOnClickPendingIntent RemoteViews.setOnClickPendingIntent(int,PendingIntent)}
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001115 * to assign PendingIntents to individual views in that custom layout (i.e., to create
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001116 * clickable buttons inside the notification view).
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001117 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001118 * @see Notification#contentIntent Notification.contentIntent
Joe Onoratocb109a02011-01-18 17:57:41 -08001119 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001120 public Builder setContentIntent(PendingIntent intent) {
1121 mContentIntent = intent;
1122 return this;
1123 }
1124
Joe Onoratocb109a02011-01-18 17:57:41 -08001125 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001126 * Supply a {@link PendingIntent} to send when the notification is cleared explicitly by the user.
1127 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001128 * @see Notification#deleteIntent
Joe Onoratocb109a02011-01-18 17:57:41 -08001129 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001130 public Builder setDeleteIntent(PendingIntent intent) {
1131 mDeleteIntent = intent;
1132 return this;
1133 }
1134
Joe Onoratocb109a02011-01-18 17:57:41 -08001135 /**
1136 * An intent to launch instead of posting the notification to the status bar.
1137 * Only for use with extremely high-priority notifications demanding the user's
1138 * <strong>immediate</strong> attention, such as an incoming phone call or
1139 * alarm clock that the user has explicitly set to a particular time.
1140 * If this facility is used for something else, please give the user an option
1141 * to turn it off and use a normal notification, as this can be extremely
1142 * disruptive.
1143 *
1144 * @param intent The pending intent to launch.
1145 * @param highPriority Passing true will cause this notification to be sent
1146 * even if other notifications are suppressed.
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001147 *
1148 * @see Notification#fullScreenIntent
Joe Onoratocb109a02011-01-18 17:57:41 -08001149 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001150 public Builder setFullScreenIntent(PendingIntent intent, boolean highPriority) {
1151 mFullScreenIntent = intent;
1152 setFlag(FLAG_HIGH_PRIORITY, highPriority);
1153 return this;
1154 }
1155
Joe Onoratocb109a02011-01-18 17:57:41 -08001156 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001157 * Set the "ticker" text which is displayed in the status bar when the notification first
Joe Onoratocb109a02011-01-18 17:57:41 -08001158 * arrives.
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001159 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001160 * @see Notification#tickerText
Joe Onoratocb109a02011-01-18 17:57:41 -08001161 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001162 public Builder setTicker(CharSequence tickerText) {
1163 mTickerText = tickerText;
1164 return this;
1165 }
1166
Joe Onoratocb109a02011-01-18 17:57:41 -08001167 /**
1168 * Set the text that is displayed in the status bar when the notification first
1169 * arrives, and also a RemoteViews object that may be displayed instead on some
1170 * devices.
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001171 *
1172 * @see Notification#tickerText
1173 * @see Notification#tickerView
Joe Onoratocb109a02011-01-18 17:57:41 -08001174 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001175 public Builder setTicker(CharSequence tickerText, RemoteViews views) {
1176 mTickerText = tickerText;
1177 mTickerView = views;
1178 return this;
1179 }
1180
Joe Onoratocb109a02011-01-18 17:57:41 -08001181 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001182 * Add a large icon to the notification (and the ticker on some devices).
1183 *
1184 * In the platform template, this image will be shown on the left of the notification view
1185 * in place of the {@link #setSmallIcon(int) small icon} (which will move to the right side).
1186 *
1187 * @see Notification#largeIcon
Joe Onoratocb109a02011-01-18 17:57:41 -08001188 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001189 public Builder setLargeIcon(Bitmap icon) {
1190 mLargeIcon = icon;
1191 return this;
1192 }
1193
Joe Onoratocb109a02011-01-18 17:57:41 -08001194 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001195 * Set the sound to play.
1196 *
1197 * It will be played on the {@link #STREAM_DEFAULT default stream} for notifications.
1198 *
1199 * @see Notification#sound
Joe Onoratocb109a02011-01-18 17:57:41 -08001200 */
Joe Onorato52f80cd2010-11-21 15:34:48 -08001201 public Builder setSound(Uri sound) {
1202 mSound = sound;
1203 mAudioStreamType = STREAM_DEFAULT;
1204 return this;
1205 }
1206
Joe Onoratocb109a02011-01-18 17:57:41 -08001207 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001208 * Set the sound to play, along with a specific stream on which to play it.
Joe Onoratocb109a02011-01-18 17:57:41 -08001209 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001210 * See {@link android.media.AudioManager} for the <code>STREAM_</code> constants.
1211 *
1212 * @see Notification#sound
Joe Onoratocb109a02011-01-18 17:57:41 -08001213 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001214 public Builder setSound(Uri sound, int streamType) {
1215 mSound = sound;
1216 mAudioStreamType = streamType;
1217 return this;
1218 }
1219
Joe Onoratocb109a02011-01-18 17:57:41 -08001220 /**
1221 * Set the vibration pattern to use.
1222 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001223
1224 * See {@link android.os.Vibrator#vibrate(long[], int)} for a discussion of the
1225 * <code>pattern</code> parameter.
1226 *
1227
1228 * @see Notification#vibrate
Joe Onoratocb109a02011-01-18 17:57:41 -08001229 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001230 public Builder setVibrate(long[] pattern) {
1231 mVibrate = pattern;
1232 return this;
1233 }
1234
Joe Onoratocb109a02011-01-18 17:57:41 -08001235 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001236 * Set the desired color for the indicator LED on the device, as well as the
1237 * blink duty cycle (specified in milliseconds).
1238 *
1239
1240 * Not all devices will honor all (or even any) of these values.
1241 *
1242
1243 * @see Notification#ledARGB
1244 * @see Notification#ledOnMS
1245 * @see Notification#ledOffMS
Joe Onoratocb109a02011-01-18 17:57:41 -08001246 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001247 public Builder setLights(int argb, int onMs, int offMs) {
1248 mLedArgb = argb;
1249 mLedOnMs = onMs;
1250 mLedOffMs = offMs;
Joe Onorato46439ce2010-11-19 13:56:21 -08001251 return this;
1252 }
1253
Joe Onoratocb109a02011-01-18 17:57:41 -08001254 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001255 * Set whether this is an "ongoing" notification.
Joe Onoratocb109a02011-01-18 17:57:41 -08001256 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001257
1258 * Ongoing notifications cannot be dismissed by the user, so your application or service
1259 * must take care of canceling them.
1260 *
1261
1262 * They are typically used to indicate a background task that the user is actively engaged
1263 * with (e.g., playing music) or is pending in some way and therefore occupying the device
1264 * (e.g., a file download, sync operation, active network connection).
1265 *
1266
1267 * @see Notification#FLAG_ONGOING_EVENT
1268 * @see Service#setForeground(boolean)
Joe Onoratocb109a02011-01-18 17:57:41 -08001269 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001270 public Builder setOngoing(boolean ongoing) {
1271 setFlag(FLAG_ONGOING_EVENT, ongoing);
1272 return this;
1273 }
1274
Joe Onoratocb109a02011-01-18 17:57:41 -08001275 /**
1276 * Set this flag if you would only like the sound, vibrate
1277 * and ticker to be played if the notification is not already showing.
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001278 *
1279 * @see Notification#FLAG_ONLY_ALERT_ONCE
Joe Onoratocb109a02011-01-18 17:57:41 -08001280 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001281 public Builder setOnlyAlertOnce(boolean onlyAlertOnce) {
1282 setFlag(FLAG_ONLY_ALERT_ONCE, onlyAlertOnce);
1283 return this;
1284 }
1285
Joe Onoratocb109a02011-01-18 17:57:41 -08001286 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001287 * Make this notification automatically dismissed when the user touches it. The
1288 * PendingIntent set with {@link #setDeleteIntent} will be sent when this happens.
1289 *
1290 * @see Notification#FLAG_AUTO_CANCEL
Joe Onoratocb109a02011-01-18 17:57:41 -08001291 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001292 public Builder setAutoCancel(boolean autoCancel) {
Joe Onorato281d83f2011-01-04 17:13:10 -08001293 setFlag(FLAG_AUTO_CANCEL, autoCancel);
Joe Onorato46439ce2010-11-19 13:56:21 -08001294 return this;
1295 }
1296
Joe Onoratocb109a02011-01-18 17:57:41 -08001297 /**
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001298 * Set which notification properties will be inherited from system defaults.
Joe Onoratocb109a02011-01-18 17:57:41 -08001299 * <p>
1300 * The value should be one or more of the following fields combined with
1301 * bitwise-or:
1302 * {@link #DEFAULT_SOUND}, {@link #DEFAULT_VIBRATE}, {@link #DEFAULT_LIGHTS}.
1303 * <p>
1304 * For all default values, use {@link #DEFAULT_ALL}.
1305 */
Joe Onorato46439ce2010-11-19 13:56:21 -08001306 public Builder setDefaults(int defaults) {
1307 mDefaults = defaults;
1308 return this;
1309 }
1310
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001311 /**
1312 * Set the priority of this notification.
1313 *
1314 * @see Notification#priority
1315 */
1316 public Builder setPriority(int pri) {
1317 mPriority = pri;
1318 return this;
1319 }
1320
1321 /**
Daniel Sandlerd33b8032012-05-10 11:41:48 -04001322 * @hide
1323 *
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001324 * Add a kind (category) to this notification. Optional.
1325 *
1326 * @see Notification#kind
1327 */
1328 public Builder addKind(String k) {
1329 mKindList.add(k);
1330 return this;
1331 }
1332
1333 /**
1334 * Add metadata to this notification.
1335 *
1336 * A reference to the Bundle is held for the lifetime of this Builder, and the Bundle's
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001337 * current contents are copied into the Notification each time {@link #build()} is
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001338 * called.
1339 *
1340 * @see Notification#extras
1341 * @hide
1342 */
1343 public Builder setExtras(Bundle bag) {
1344 mExtras = bag;
1345 return this;
1346 }
1347
Daniel Sandlera0a938c2012-03-15 08:42:37 -04001348 /**
1349 * Add an action to this notification. Actions are typically displayed by
1350 * the system as a button adjacent to the notification content.
1351 *
1352 * @param icon Resource ID of a drawable that represents the action.
1353 * @param title Text describing the action.
1354 * @param intent PendingIntent to be fired when the action is invoked.
1355 */
1356 public Builder addAction(int icon, CharSequence title, PendingIntent intent) {
1357 mActions.add(new Action(icon, title, intent));
1358 return this;
1359 }
1360
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001361 /**
1362 * Add a rich notification style to be applied at build time.
1363 *
1364 * @param style Object responsible for modifying the notification style.
1365 */
1366 public Builder setStyle(Style style) {
1367 if (mStyle != style) {
1368 mStyle = style;
1369 mStyle.setBuilder(this);
1370 }
1371 return this;
1372 }
1373
Joe Onorato46439ce2010-11-19 13:56:21 -08001374 private void setFlag(int mask, boolean value) {
1375 if (value) {
1376 mFlags |= mask;
1377 } else {
1378 mFlags &= ~mask;
1379 }
1380 }
1381
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001382 private RemoteViews applyStandardTemplate(int resId) {
Joe Onorato561d3852010-11-20 18:09:34 -08001383 RemoteViews contentView = new RemoteViews(mContext.getPackageName(), resId);
Daniel Sandler9f7936a2012-05-21 16:14:28 -04001384 boolean showLine3 = false;
1385 boolean showLine2 = false;
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001386 int smallIconImageViewId = R.id.icon;
1387 if (mLargeIcon != null) {
1388 contentView.setImageViewBitmap(R.id.icon, mLargeIcon);
1389 smallIconImageViewId = R.id.right_icon;
1390 }
Daniel Sandlere95658c2012-05-10 00:33:54 -04001391 if (mPriority < PRIORITY_LOW) {
1392 contentView.setInt(R.id.icon,
1393 "setBackgroundResource", R.drawable.notification_template_icon_low_bg);
1394 contentView.setInt(R.id.status_bar_latest_event_content,
1395 "setBackgroundResource", R.drawable.notification_bg_low);
1396 }
Joe Onorato561d3852010-11-20 18:09:34 -08001397 if (mSmallIcon != 0) {
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001398 contentView.setImageViewResource(smallIconImageViewId, mSmallIcon);
1399 contentView.setViewVisibility(smallIconImageViewId, View.VISIBLE);
Jeff Sharkey1c400132011-08-05 14:50:13 -07001400 } else {
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001401 contentView.setViewVisibility(smallIconImageViewId, View.GONE);
Joe Onorato561d3852010-11-20 18:09:34 -08001402 }
1403 if (mContentTitle != null) {
1404 contentView.setTextViewText(R.id.title, mContentTitle);
1405 }
1406 if (mContentText != null) {
Daniel Sandler9f7936a2012-05-21 16:14:28 -04001407 contentView.setTextViewText(R.id.text, mContentText);
1408 showLine3 = true;
Joe Onorato561d3852010-11-20 18:09:34 -08001409 }
1410 if (mContentInfo != null) {
1411 contentView.setTextViewText(R.id.info, mContentInfo);
Jeff Sharkey1c400132011-08-05 14:50:13 -07001412 contentView.setViewVisibility(R.id.info, View.VISIBLE);
Daniel Sandler9f7936a2012-05-21 16:14:28 -04001413 showLine3 = true;
Joe Onorato561d3852010-11-20 18:09:34 -08001414 } else if (mNumber > 0) {
Daniel Sandlerebce0112011-06-16 16:44:51 -04001415 final int tooBig = mContext.getResources().getInteger(
1416 R.integer.status_bar_notification_info_maxnum);
1417 if (mNumber > tooBig) {
1418 contentView.setTextViewText(R.id.info, mContext.getResources().getString(
1419 R.string.status_bar_notification_info_overflow));
Joe Onorato059a2f82011-01-04 10:27:01 -08001420 } else {
1421 NumberFormat f = NumberFormat.getIntegerInstance();
1422 contentView.setTextViewText(R.id.info, f.format(mNumber));
1423 }
Jeff Sharkey1c400132011-08-05 14:50:13 -07001424 contentView.setViewVisibility(R.id.info, View.VISIBLE);
Daniel Sandler9f7936a2012-05-21 16:14:28 -04001425 showLine3 = true;
Joe Onorato561d3852010-11-20 18:09:34 -08001426 } else {
1427 contentView.setViewVisibility(R.id.info, View.GONE);
1428 }
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001429
Daniel Sandler9f7936a2012-05-21 16:14:28 -04001430 // Need to show three lines?
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001431 if (mSubText != null) {
1432 contentView.setTextViewText(R.id.text, mSubText);
Daniel Sandler9f7936a2012-05-21 16:14:28 -04001433 if (mContentText != null) {
1434 contentView.setTextViewText(R.id.text2, mContentText);
1435 // need to shrink all the type to make sure everything fits
1436 contentView.setViewVisibility(R.id.text2, View.VISIBLE);
1437 showLine2 = true;
1438 } else {
1439 contentView.setViewVisibility(R.id.text2, View.GONE);
1440 }
Jeff Sharkey1c400132011-08-05 14:50:13 -07001441 } else {
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001442 contentView.setViewVisibility(R.id.text2, View.GONE);
1443 if (mProgressMax != 0 || mProgressIndeterminate) {
1444 contentView.setProgressBar(
1445 R.id.progress, mProgressMax, mProgress, mProgressIndeterminate);
1446 contentView.setViewVisibility(R.id.progress, View.VISIBLE);
Daniel Sandler9f7936a2012-05-21 16:14:28 -04001447 showLine2 = true;
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001448 } else {
1449 contentView.setViewVisibility(R.id.progress, View.GONE);
1450 }
Jeff Sharkey1c400132011-08-05 14:50:13 -07001451 }
Daniel Sandler9f7936a2012-05-21 16:14:28 -04001452 if (showLine2) {
1453 final Resources res = mContext.getResources();
1454 final float subTextSize = res.getDimensionPixelSize(
1455 R.dimen.notification_subtext_size);
1456 contentView.setTextViewTextSize(R.id.text, TypedValue.COMPLEX_UNIT_PX, subTextSize);
1457 // vertical centering
1458 contentView.setViewPadding(R.id.line1, 0, 0, 0, 0);
1459 }
1460
Joe Onorato561d3852010-11-20 18:09:34 -08001461 if (mWhen != 0) {
Daniel Sandlera2985ed2012-04-03 16:42:00 -04001462 if (mUseChronometer) {
1463 contentView.setViewVisibility(R.id.chronometer, View.VISIBLE);
1464 contentView.setLong(R.id.chronometer, "setBase",
1465 mWhen + (SystemClock.elapsedRealtime() - System.currentTimeMillis()));
1466 contentView.setBoolean(R.id.chronometer, "setStarted", true);
1467 } else {
1468 contentView.setViewVisibility(R.id.time, View.VISIBLE);
1469 contentView.setLong(R.id.time, "setTime", mWhen);
1470 }
Joe Onorato561d3852010-11-20 18:09:34 -08001471 }
Daniel Sandler9f7936a2012-05-21 16:14:28 -04001472 contentView.setViewVisibility(R.id.line3, showLine3 ? View.VISIBLE : View.GONE);
Joe Onorato561d3852010-11-20 18:09:34 -08001473 return contentView;
1474 }
1475
Daniel Sandler96fd7c12012-03-30 16:37:36 -04001476 private RemoteViews applyStandardTemplateWithActions(int layoutId) {
1477 RemoteViews big = applyStandardTemplate(layoutId);
1478
1479 int N = mActions.size();
1480 if (N > 0) {
Chris Wrend6297db2012-05-03 16:20:13 -04001481 // Log.d("Notification", "has actions: " + mContentText);
Daniel Sandler96fd7c12012-03-30 16:37:36 -04001482 big.setViewVisibility(R.id.actions, View.VISIBLE);
Daniel Sandler8680bf82012-05-15 16:52:52 -04001483 if (N>MAX_ACTION_BUTTONS) N=MAX_ACTION_BUTTONS;
Chris Wren2c22eb02012-05-08 09:49:13 -04001484 big.removeAllViews(R.id.actions);
Daniel Sandler96fd7c12012-03-30 16:37:36 -04001485 for (int i=0; i<N; i++) {
1486 final RemoteViews button = generateActionButton(mActions.get(i));
Chris Wrend6297db2012-05-03 16:20:13 -04001487 //Log.d("Notification", "adding action " + i + ": " + mActions.get(i).title);
Daniel Sandler96fd7c12012-03-30 16:37:36 -04001488 big.addView(R.id.actions, button);
1489 }
1490 }
1491 return big;
1492 }
1493
Joe Onorato46439ce2010-11-19 13:56:21 -08001494 private RemoteViews makeContentView() {
1495 if (mContentView != null) {
1496 return mContentView;
1497 } else {
Daniel Sandler96fd7c12012-03-30 16:37:36 -04001498 return applyStandardTemplate(R.layout.notification_template_base); // no more special large_icon flavor
Joe Onorato46439ce2010-11-19 13:56:21 -08001499 }
1500 }
1501
1502 private RemoteViews makeTickerView() {
1503 if (mTickerView != null) {
1504 return mTickerView;
1505 } else {
Joe Onorato561d3852010-11-20 18:09:34 -08001506 if (mContentView == null) {
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001507 return applyStandardTemplate(mLargeIcon == null
Joe Onorato561d3852010-11-20 18:09:34 -08001508 ? R.layout.status_bar_latest_event_ticker
1509 : R.layout.status_bar_latest_event_ticker_large_icon);
1510 } else {
1511 return null;
1512 }
Joe Onorato46439ce2010-11-19 13:56:21 -08001513 }
1514 }
1515
Daniel Sandler96fd7c12012-03-30 16:37:36 -04001516 private RemoteViews makeBigContentView() {
1517 if (mActions.size() == 0) return null;
1518
Chris Wrenb023bf82012-04-23 16:05:42 -04001519 return applyStandardTemplateWithActions(R.layout.notification_template_big_base);
Daniel Sandler96fd7c12012-03-30 16:37:36 -04001520 }
1521
Daniel Sandler96fd7c12012-03-30 16:37:36 -04001522 private RemoteViews generateActionButton(Action action) {
Daniel Sandler8680bf82012-05-15 16:52:52 -04001523 final boolean tombstone = (action.actionIntent == null);
1524 RemoteViews button = new RemoteViews(mContext.getPackageName(),
1525 tombstone ? R.layout.notification_action_tombstone
1526 : R.layout.notification_action);
Daniel Sandler96fd7c12012-03-30 16:37:36 -04001527 button.setTextViewCompoundDrawables(R.id.action0, action.icon, 0, 0, 0);
1528 button.setTextViewText(R.id.action0, action.title);
Daniel Sandler8680bf82012-05-15 16:52:52 -04001529 if (!tombstone) {
Daniel Sandlere5518842012-05-10 16:20:40 -04001530 button.setOnClickPendingIntent(R.id.action0, action.actionIntent);
Daniel Sandlere5518842012-05-10 16:20:40 -04001531 }
Daniel Sandler96fd7c12012-03-30 16:37:36 -04001532 button.setContentDescription(R.id.action0, action.title);
1533 return button;
1534 }
1535
Joe Onoratocb109a02011-01-18 17:57:41 -08001536 /**
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001537 * Apply the unstyled operations and return a new {@link Notification} object.
Joe Onoratocb109a02011-01-18 17:57:41 -08001538 */
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001539 private Notification buildUnstyled() {
Joe Onorato46439ce2010-11-19 13:56:21 -08001540 Notification n = new Notification();
1541 n.when = mWhen;
1542 n.icon = mSmallIcon;
1543 n.iconLevel = mSmallIconLevel;
Joe Onorato8595a3d2010-11-19 18:12:07 -08001544 n.number = mNumber;
Joe Onorato46439ce2010-11-19 13:56:21 -08001545 n.contentView = makeContentView();
1546 n.contentIntent = mContentIntent;
1547 n.deleteIntent = mDeleteIntent;
1548 n.fullScreenIntent = mFullScreenIntent;
1549 n.tickerText = mTickerText;
1550 n.tickerView = makeTickerView();
1551 n.largeIcon = mLargeIcon;
1552 n.sound = mSound;
1553 n.audioStreamType = mAudioStreamType;
1554 n.vibrate = mVibrate;
1555 n.ledARGB = mLedArgb;
1556 n.ledOnMS = mLedOnMs;
1557 n.ledOffMS = mLedOffMs;
1558 n.defaults = mDefaults;
1559 n.flags = mFlags;
Daniel Sandler96fd7c12012-03-30 16:37:36 -04001560 n.bigContentView = makeBigContentView();
Joe Onorato8d0b6552010-11-22 16:09:29 -08001561 if (mLedOnMs != 0 && mLedOffMs != 0) {
1562 n.flags |= FLAG_SHOW_LIGHTS;
1563 }
1564 if ((mDefaults & DEFAULT_LIGHTS) != 0) {
1565 n.flags |= FLAG_SHOW_LIGHTS;
1566 }
Daniel Sandler2561b0b2012-02-13 21:04:12 -05001567 if (mKindList.size() > 0) {
1568 n.kind = new String[mKindList.size()];
1569 mKindList.toArray(n.kind);
1570 } else {
1571 n.kind = null;
1572 }
1573 n.priority = mPriority;
1574 n.extras = mExtras != null ? new Bundle(mExtras) : null;
Daniel Sandlera0a938c2012-03-15 08:42:37 -04001575 if (mActions.size() > 0) {
1576 n.actions = new Action[mActions.size()];
1577 mActions.toArray(n.actions);
1578 }
Joe Onorato46439ce2010-11-19 13:56:21 -08001579 return n;
1580 }
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001581
1582 /**
1583 * @deprecated Use {@link #build()} instead.
1584 */
1585 @Deprecated
1586 public Notification getNotification() {
1587 return build();
1588 }
1589
1590 /**
1591 * Combine all of the options that have been set and return a new {@link Notification}
1592 * object.
1593 */
1594 public Notification build() {
1595 if (mStyle != null) {
1596 return mStyle.build();
1597 } else {
1598 return buildUnstyled();
1599 }
1600 }
1601 }
1602
1603
1604 /**
1605 * An object that can apply a rich notification style to a {@link Notification.Builder}
1606 * object.
1607 */
Chris Wrend6297db2012-05-03 16:20:13 -04001608 public static abstract class Style
1609 {
1610 private CharSequence mBigContentTitle;
1611 private CharSequence mSummaryText = null;
1612
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001613 protected Builder mBuilder;
1614
Chris Wrend6297db2012-05-03 16:20:13 -04001615 /**
1616 * Overrides ContentTitle in the big form of the template.
1617 * This defaults to the value passed to setContentTitle().
1618 */
1619 protected void internalSetBigContentTitle(CharSequence title) {
1620 mBigContentTitle = title;
1621 }
1622
1623 /**
1624 * Set the first line of text after the detail section in the big form of the template.
1625 */
1626 protected void internalSetSummaryText(CharSequence cs) {
1627 mSummaryText = cs;
1628 }
1629
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001630 public void setBuilder(Builder builder) {
1631 if (mBuilder != builder) {
1632 mBuilder = builder;
1633 mBuilder.setStyle(this);
1634 }
1635 }
1636
Chris Wrend6297db2012-05-03 16:20:13 -04001637 protected void checkBuilder() {
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001638 if (mBuilder == null) {
1639 throw new IllegalArgumentException("Style requires a valid Builder object");
1640 }
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001641 }
Chris Wrend6297db2012-05-03 16:20:13 -04001642
1643 protected RemoteViews getStandardView(int layoutId) {
1644 checkBuilder();
1645
1646 if (mBigContentTitle != null) {
1647 mBuilder.setContentTitle(mBigContentTitle);
1648 }
1649
Chris Wrend6297db2012-05-03 16:20:13 -04001650 RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(layoutId);
1651
Chris Wrend6297db2012-05-03 16:20:13 -04001652 if (mBigContentTitle != null && mBigContentTitle.equals("")) {
1653 contentView.setViewVisibility(R.id.line1, View.GONE);
Chris Wren67dc9a02012-05-16 01:03:20 -04001654 } else {
1655 contentView.setViewVisibility(R.id.line1, View.VISIBLE);
Chris Wrend6297db2012-05-03 16:20:13 -04001656 }
1657
1658 if (mSummaryText != null && !mSummaryText.equals("")) {
1659 contentView.setViewVisibility(R.id.overflow_title, View.VISIBLE);
1660 contentView.setTextViewText(R.id.overflow_title, mSummaryText);
Daniel Sandler9f7936a2012-05-21 16:14:28 -04001661 contentView.setViewVisibility(R.id.line3, View.GONE);
Chris Wren67dc9a02012-05-16 01:03:20 -04001662 } else {
1663 contentView.setViewVisibility(R.id.overflow_title, View.GONE);
Daniel Sandler9f7936a2012-05-21 16:14:28 -04001664 contentView.setViewVisibility(R.id.line3, View.VISIBLE);
Chris Wrend6297db2012-05-03 16:20:13 -04001665 }
1666
1667 return contentView;
1668 }
1669
1670 public abstract Notification build();
Joe Onorato46439ce2010-11-19 13:56:21 -08001671 }
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001672
1673 /**
Daniel Sandler4dfbe832012-04-11 14:51:46 -04001674 * Helper class for generating large-format notifications that include a large image attachment.
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001675 *
Daniel Sandler4dfbe832012-04-11 14:51:46 -04001676 * This class is a "rebuilder": It consumes a Builder object and modifies its behavior, like so:
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001677 * <pre class="prettyprint">
1678 * Notification noti = new Notification.BigPictureStyle(
1679 * new Notification.Builder()
Daniel Sandler4dfbe832012-04-11 14:51:46 -04001680 * .setContentTitle(&quot;New photo from &quot; + sender.toString())
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001681 * .setContentText(subject)
Daniel Sandler4dfbe832012-04-11 14:51:46 -04001682 * .setSmallIcon(R.drawable.new_post)
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001683 * .setLargeIcon(aBitmap))
1684 * .bigPicture(aBigBitmap)
1685 * .build();
1686 * </pre>
Daniel Sandler4dfbe832012-04-11 14:51:46 -04001687 *
1688 * @see Notification#bigContentView
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001689 */
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001690 public static class BigPictureStyle extends Style {
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001691 private Bitmap mPicture;
Chris Wren3745a3d2012-05-22 15:11:52 -04001692 private Bitmap mBigLargeIcon;
1693 private boolean mBigLargeIconSet = false;
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001694
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001695 public BigPictureStyle() {
1696 }
1697
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001698 public BigPictureStyle(Builder builder) {
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001699 setBuilder(builder);
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001700 }
1701
Chris Wrend6297db2012-05-03 16:20:13 -04001702 /**
1703 * Overrides ContentTitle in the big form of the template.
1704 * This defaults to the value passed to setContentTitle().
1705 */
1706 public BigPictureStyle setBigContentTitle(CharSequence title) {
1707 internalSetBigContentTitle(title);
1708 return this;
1709 }
1710
1711 /**
1712 * Set the first line of text after the detail section in the big form of the template.
1713 */
1714 public BigPictureStyle setSummaryText(CharSequence cs) {
1715 internalSetSummaryText(cs);
1716 return this;
1717 }
1718
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001719 public BigPictureStyle bigPicture(Bitmap b) {
1720 mPicture = b;
1721 return this;
1722 }
1723
Chris Wren3745a3d2012-05-22 15:11:52 -04001724 /**
1725 * @hide
1726 * Override the large icon when the big notification is shown.
1727 */
1728 public BigPictureStyle bigLargeIcon(Bitmap b) {
1729 mBigLargeIconSet = true;
1730 mBigLargeIcon = b;
1731 return this;
1732 }
1733
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001734 private RemoteViews makeBigContentView() {
Chris Wrend6297db2012-05-03 16:20:13 -04001735 RemoteViews contentView = getStandardView(R.layout.notification_template_big_picture);
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001736
1737 contentView.setImageViewBitmap(R.id.big_picture, mPicture);
1738
1739 return contentView;
1740 }
1741
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001742 @Override
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001743 public Notification build() {
Chris Wrend6297db2012-05-03 16:20:13 -04001744 checkBuilder();
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001745 Notification wip = mBuilder.buildUnstyled();
Chris Wren3745a3d2012-05-22 15:11:52 -04001746 if (mBigLargeIconSet ) {
1747 mBuilder.mLargeIcon = mBigLargeIcon;
1748 }
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001749 wip.bigContentView = makeBigContentView();
1750 return wip;
1751 }
1752 }
1753
1754 /**
Daniel Sandler4dfbe832012-04-11 14:51:46 -04001755 * Helper class for generating large-format notifications that include a lot of text.
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001756 *
Daniel Sandler4dfbe832012-04-11 14:51:46 -04001757 * This class is a "rebuilder": It consumes a Builder object and modifies its behavior, like so:
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001758 * <pre class="prettyprint">
1759 * Notification noti = new Notification.BigPictureStyle(
1760 * new Notification.Builder()
1761 * .setContentTitle(&quot;New mail from &quot; + sender.toString())
1762 * .setContentText(subject)
1763 * .setSmallIcon(R.drawable.new_mail)
1764 * .setLargeIcon(aBitmap))
1765 * .bigText(aVeryLongString)
1766 * .build();
1767 * </pre>
Daniel Sandler4dfbe832012-04-11 14:51:46 -04001768 *
1769 * @see Notification#bigContentView
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001770 */
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001771 public static class BigTextStyle extends Style {
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001772 private CharSequence mBigText;
1773
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001774 public BigTextStyle() {
1775 }
1776
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001777 public BigTextStyle(Builder builder) {
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001778 setBuilder(builder);
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001779 }
1780
Chris Wrend6297db2012-05-03 16:20:13 -04001781 /**
1782 * Overrides ContentTitle in the big form of the template.
1783 * This defaults to the value passed to setContentTitle().
1784 */
1785 public BigTextStyle setBigContentTitle(CharSequence title) {
1786 internalSetBigContentTitle(title);
1787 return this;
1788 }
1789
1790 /**
1791 * Set the first line of text after the detail section in the big form of the template.
1792 */
1793 public BigTextStyle setSummaryText(CharSequence cs) {
1794 internalSetSummaryText(cs);
1795 return this;
1796 }
1797
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001798 public BigTextStyle bigText(CharSequence cs) {
1799 mBigText = cs;
1800 return this;
1801 }
1802
1803 private RemoteViews makeBigContentView() {
Chris Wrend6297db2012-05-03 16:20:13 -04001804 RemoteViews contentView = getStandardView(R.layout.notification_template_big_text);
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001805 contentView.setTextViewText(R.id.big_text, mBigText);
1806 contentView.setViewVisibility(R.id.big_text, View.VISIBLE);
Chris Wren3c5f92432012-05-04 16:31:17 -04001807 contentView.setViewVisibility(R.id.text2, View.GONE);
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001808
1809 return contentView;
1810 }
1811
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001812 @Override
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001813 public Notification build() {
Chris Wrend6297db2012-05-03 16:20:13 -04001814 checkBuilder();
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001815 Notification wip = mBuilder.buildUnstyled();
Daniel Sandlerf3b73432012-03-27 15:01:25 -04001816 wip.bigContentView = makeBigContentView();
1817 return wip;
1818 }
1819 }
Daniel Sandler879c5e02012-04-17 16:46:51 -04001820
1821 /**
1822 * Helper class for generating large-format notifications that include a list of (up to 5) strings.
1823 *
1824 * This class is a "rebuilder": It consumes a Builder object and modifies its behavior, like so:
1825 * <pre class="prettyprint">
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001826 * Notification noti = new Notification.InboxStyle(
Daniel Sandler879c5e02012-04-17 16:46:51 -04001827 * new Notification.Builder()
Chris Wrend6297db2012-05-03 16:20:13 -04001828 * .setContentTitle(&quot;5 New mails from &quot; + sender.toString())
Daniel Sandler879c5e02012-04-17 16:46:51 -04001829 * .setContentText(subject)
1830 * .setSmallIcon(R.drawable.new_mail)
1831 * .setLargeIcon(aBitmap))
1832 * .addLine(str1)
1833 * .addLine(str2)
Chris Wrend6297db2012-05-03 16:20:13 -04001834 * .setContentTitle("")
1835 * .setSummaryText(&quot;+3 more&quot;)
Daniel Sandler879c5e02012-04-17 16:46:51 -04001836 * .build();
1837 * </pre>
1838 *
1839 * @see Notification#bigContentView
1840 */
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001841 public static class InboxStyle extends Style {
Daniel Sandler879c5e02012-04-17 16:46:51 -04001842 private ArrayList<CharSequence> mTexts = new ArrayList<CharSequence>(5);
1843
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001844 public InboxStyle() {
1845 }
1846
Daniel Sandler879c5e02012-04-17 16:46:51 -04001847 public InboxStyle(Builder builder) {
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001848 setBuilder(builder);
Daniel Sandler879c5e02012-04-17 16:46:51 -04001849 }
1850
Chris Wrend6297db2012-05-03 16:20:13 -04001851 /**
1852 * Overrides ContentTitle in the big form of the template.
1853 * This defaults to the value passed to setContentTitle().
1854 */
1855 public InboxStyle setBigContentTitle(CharSequence title) {
1856 internalSetBigContentTitle(title);
1857 return this;
1858 }
1859
1860 /**
1861 * Set the first line of text after the detail section in the big form of the template.
1862 */
1863 public InboxStyle setSummaryText(CharSequence cs) {
1864 internalSetSummaryText(cs);
1865 return this;
1866 }
1867
Daniel Sandler879c5e02012-04-17 16:46:51 -04001868 public InboxStyle addLine(CharSequence cs) {
1869 mTexts.add(cs);
1870 return this;
1871 }
1872
1873 private RemoteViews makeBigContentView() {
Chris Wrend6297db2012-05-03 16:20:13 -04001874 RemoteViews contentView = getStandardView(R.layout.notification_template_inbox);
1875 contentView.setViewVisibility(R.id.text2, View.GONE);
Daniel Sandler879c5e02012-04-17 16:46:51 -04001876
Chris Wrend6297db2012-05-03 16:20:13 -04001877 int[] rowIds = {R.id.inbox_text0, R.id.inbox_text1, R.id.inbox_text2, R.id.inbox_text3,
Chris Wren29bb6d92012-05-17 18:09:42 -04001878 R.id.inbox_text4, R.id.inbox_text5, R.id.inbox_text6};
Chris Wrend6297db2012-05-03 16:20:13 -04001879
Chris Wren4ed80d52012-05-17 09:30:03 -04001880 // Make sure all rows are gone in case we reuse a view.
1881 for (int rowId : rowIds) {
1882 contentView.setViewVisibility(rowId, View.GONE);
1883 }
1884
Daniel Sandler879c5e02012-04-17 16:46:51 -04001885 int i=0;
1886 while (i < mTexts.size() && i < rowIds.length) {
1887 CharSequence str = mTexts.get(i);
1888 if (str != null && !str.equals("")) {
1889 contentView.setViewVisibility(rowIds[i], View.VISIBLE);
1890 contentView.setTextViewText(rowIds[i], str);
1891 }
1892 i++;
1893 }
1894
Chris Wren29bb6d92012-05-17 18:09:42 -04001895 if (mTexts.size() > rowIds.length) {
1896 contentView.setViewVisibility(R.id.inbox_more, View.VISIBLE);
1897 } else {
1898 contentView.setViewVisibility(R.id.inbox_more, View.GONE);
1899 }
1900
Daniel Sandler879c5e02012-04-17 16:46:51 -04001901 return contentView;
1902 }
1903
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001904 @Override
Daniel Sandler879c5e02012-04-17 16:46:51 -04001905 public Notification build() {
Chris Wrend6297db2012-05-03 16:20:13 -04001906 checkBuilder();
Chris Wrenfbd96ba2012-05-01 12:03:58 -04001907 Notification wip = mBuilder.buildUnstyled();
Daniel Sandler879c5e02012-04-17 16:46:51 -04001908 wip.bigContentView = makeBigContentView();
1909 return wip;
1910 }
1911 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001912}