blob: 2a3f14340a39d60b85e905f6a082c51f4c82ada1 [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 com.android.statusbartest;
18
Joe Onoratoef1e7762010-09-17 18:38:38 -040019import android.app.Notification;
20import android.app.NotificationManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.app.PendingIntent;
Christian Mehlmaueref367522010-05-31 23:08:30 +020022import android.content.Context;
The Android Open Source Project4df24232009-03-05 14:34:35 -080023import android.content.ContentResolver;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024import android.content.Intent;
Joe Onoratoef1e7762010-09-17 18:38:38 -040025import android.graphics.Bitmap;
Julia Reynoldsa07af882015-12-17 08:32:48 -050026import android.graphics.BitmapFactory;
Joe Onoratoef1e7762010-09-17 18:38:38 -040027import android.graphics.drawable.BitmapDrawable;
Daniel Sandlerbc5559f2012-04-19 01:08:15 -040028import android.os.Bundle;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029import android.os.Vibrator;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030import android.os.Handler;
Dianne Hackborn41203752012-08-31 14:05:51 -070031import android.os.UserHandle;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032import android.util.Log;
33import android.net.Uri;
34import android.os.SystemClock;
35import android.widget.RemoteViews;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036import android.os.PowerManager;
37
Daniel Sandlere40451a2011-02-03 14:51:35 -050038// private NM API
39import android.app.INotificationManager;
Julia Reynolds81afbcd2016-02-09 14:54:08 -050040import android.widget.Toast;
Daniel Sandlere40451a2011-02-03 14:51:35 -050041
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080042public class NotificationTestList extends TestActivity
43{
44 private final static String TAG = "NotificationTestList";
45
46 NotificationManager mNM;
Daniel Sandlerbc5559f2012-04-19 01:08:15 -040047 Vibrator mVibrator;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080048 Handler mHandler = new Handler();
49
Daniel Sandlerbc5559f2012-04-19 01:08:15 -040050 long mActivityCreateTime;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080051 long mChronometerBase = 0;
52
Daniel Sandler373a9982010-11-30 12:03:59 -050053 boolean mProgressDone = true;
54
Daniel Sandlerb0cc50d2010-10-26 16:55:56 -040055 final int[] kNumberedIconResIDs = {
56 R.drawable.notification0,
57 R.drawable.notification1,
58 R.drawable.notification2,
59 R.drawable.notification3,
60 R.drawable.notification4,
61 R.drawable.notification5,
62 R.drawable.notification6,
63 R.drawable.notification7,
64 R.drawable.notification8,
65 R.drawable.notification9
66 };
67 final int kUnnumberedIconResID = R.drawable.notificationx;
68
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080069 @Override
Daniel Sandlerbc5559f2012-04-19 01:08:15 -040070 public void onCreate(Bundle icicle) {
71 super.onCreate(icicle);
72 mVibrator = (Vibrator)getSystemService(VIBRATOR_SERVICE);
73 mActivityCreateTime = System.currentTimeMillis();
74 }
75
76 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080077 protected String tag() {
78 return TAG;
79 }
80
81 @Override
82 protected Test[] tests() {
83 mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
84
85 return mTests;
86 }
87
88 private Test[] mTests = new Test[] {
Julia Reynoldsf0f629f2016-02-25 09:34:04 -050089 new Test("Min priority") {
90 public void run()
91 {
92 Notification n = new Notification.Builder(NotificationTestList.this)
93 .setSmallIcon(R.drawable.icon2)
94 .setContentTitle("Min priority")
95 .setLights(0xff0000ff, 1, 0)
96 .setDefaults(Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
97 .setSound(Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
98 getPackageName() + "/raw/ringer"))
99 .setPriority(Notification.PRIORITY_MIN)
100 .setFullScreenIntent(makeIntent2(), false)
101 .build();
102 mNM.notify(7000, n);
103 }
104 },
105 new Test("Min priority, high pri flag") {
106 public void run()
107 {
108 Notification n = new Notification.Builder(NotificationTestList.this)
109 .setSmallIcon(R.drawable.icon2)
110 .setContentTitle("Min priority, high pri flag")
111 .setLights(0xff0000ff, 1, 0)
112 .setDefaults(Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
113 .setSound(Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
114 getPackageName() + "/raw/ringer"))
115 .setPriority(Notification.PRIORITY_MIN)
116 .setFullScreenIntent(makeIntent2(), true)
117 .build();
118 mNM.notify(7001, n);
119 }
120 },
121 new Test("Low priority") {
122 public void run()
123 {
124 Notification n = new Notification.Builder(NotificationTestList.this)
125 .setSmallIcon(R.drawable.icon2)
126 .setContentTitle("Low priority")
127 .setLights(0xff0000ff, 1, 0)
128 .setDefaults(Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
129 .setSound(Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
130 getPackageName() + "/raw/ringer"))
131 .setPriority(Notification.PRIORITY_LOW)
132 .setFullScreenIntent(makeIntent2(), false)
133 .build();
134 mNM.notify(7002, n);
135 }
136 },
137 new Test("Default priority") {
138 public void run()
139 {
140 Notification n = new Notification.Builder(NotificationTestList.this)
141 .setSmallIcon(R.drawable.icon2)
142 .setContentTitle("Default priority")
143 .setLights(0xff0000ff, 1, 0)
144 .setDefaults(Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
145 .setSound(Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
146 getPackageName() + "/raw/ringer"))
147 .setPriority(Notification.PRIORITY_DEFAULT)
148 .setFullScreenIntent(makeIntent2(), false)
149 .build();
150 mNM.notify(7004, n);
151 }
152 },
153 new Test("High priority") {
154 public void run()
155 {
156 Notification n = new Notification.Builder(NotificationTestList.this)
157 .setSmallIcon(R.drawable.icon2)
158 .setContentTitle("High priority")
159 .setLights(0xff0000ff, 1, 0)
160 .setDefaults(Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
161 .setSound(Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
162 getPackageName() + "/raw/ringer"))
163 .setPriority(Notification.PRIORITY_HIGH)
164 .setFullScreenIntent(makeIntent2(), false)
165 .build();
166 mNM.notify(7006, n);
167 }
168 },
169 new Test("Max priority") {
170 public void run()
171 {
172 Notification n = new Notification.Builder(NotificationTestList.this)
173 .setSmallIcon(R.drawable.icon2)
174 .setContentTitle("Max priority")
175 .setLights(0xff0000ff, 1, 0)
176 .setDefaults(Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
177 .setSound(Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
178 getPackageName() + "/raw/ringer"))
179 .setPriority(Notification.PRIORITY_MAX)
180 .setFullScreenIntent(makeIntent2(), false)
181 .build();
182 mNM.notify(7008, n);
183 }
184 },
185 new Test("Max priority with delay") {
186 public void run()
187 {
188 try {
189 Thread.sleep(5000);
190 } catch (InterruptedException e) {
191 }
192 Notification n = new Notification.Builder(NotificationTestList.this)
193 .setSmallIcon(R.drawable.icon2)
194 .setContentTitle("Max priority")
195 .setLights(0xff0000ff, 1, 0)
196 .setDefaults(Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
197 .setSound(Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
198 getPackageName() + "/raw/ringer"))
199 .setPriority(Notification.PRIORITY_MAX)
200 .setFullScreenIntent(makeIntent2(), false)
201 .build();
202 mNM.notify(7008, n);
203 }
204 },
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400205 new Test("Off") {
Joe Onoratoe71d9e42009-11-05 17:12:18 -0500206 public void run() {
Christian Mehlmaueref367522010-05-31 23:08:30 +0200207 PowerManager pm = (PowerManager)NotificationTestList.this.getSystemService(Context.POWER_SERVICE);
Joe Onoratoe71d9e42009-11-05 17:12:18 -0500208 PowerManager.WakeLock wl =
209 pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "sound");
210 wl.acquire();
211
212 pm.goToSleep(SystemClock.uptimeMillis());
213
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400214 Notification n = new Notification.Builder(NotificationTestList.this)
215 .setSmallIcon(R.drawable.stat_sys_phone)
216 .setContentTitle(name)
217 .setSound(Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
218 getPackageName() + "/raw/ringer"))
219 .build();
Joe Onoratoe71d9e42009-11-05 17:12:18 -0500220 Log.d(TAG, "n.sound=" + n.sound);
221
222 mNM.notify(1, n);
223
224 Log.d(TAG, "releasing wake lock");
225 wl.release();
226 Log.d(TAG, "released wake lock");
227 }
228 },
229
Joe Onoratoef1e7762010-09-17 18:38:38 -0400230 new Test("Cancel #1") {
231 public void run()
232 {
233 mNM.cancel(1);
234 }
235 },
236
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400237 new Test("Custom Button") {
Joe Onorato4058ba02010-10-31 11:38:04 -0700238 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400239 Notification n = new Notification.Builder(NotificationTestList.this)
240 .setSmallIcon(R.drawable.icon1)
241 .setWhen(mActivityCreateTime)
242 .setContentTitle(name)
243 .setOngoing(true)
244 .build();
Joe Onorato4058ba02010-10-31 11:38:04 -0700245 n.contentView = new RemoteViews(getPackageName(), R.layout.button_notification);
Joe Onorato4058ba02010-10-31 11:38:04 -0700246 n.contentView.setOnClickPendingIntent(R.id.button, makeIntent2());
247
248 mNM.notify(1, n);
249 }
250 },
251
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400252 new Test("Action Button") {
Joe Onorato184498c2010-10-08 17:57:18 -0400253 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400254 Notification n = new Notification.Builder(NotificationTestList.this)
255 .setSmallIcon(R.drawable.icon1)
256 .setWhen(mActivityCreateTime)
257 .setContentTitle(name)
258 .setOngoing(true)
259 .addAction(R.drawable.ic_statusbar_chat, "Button", makeIntent2())
260 .build();
261
Joe Onorato184498c2010-10-08 17:57:18 -0400262 mNM.notify(1, n);
263 }
264 },
265
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400266 new Test("with intent") {
Joe Onoratoef1e7762010-09-17 18:38:38 -0400267 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400268 Notification n = new Notification.Builder(NotificationTestList.this)
269 .setSmallIcon(R.drawable.icon1)
270 .setWhen(mActivityCreateTime)
271 .setContentTitle("Persistent #1")
272 .setContentText("This is a notification!!!")
273 .setContentIntent(makeIntent2())
274 .setOngoing(true)
275 .build();
276
Joe Onoratoef1e7762010-09-17 18:38:38 -0400277 mNM.notify(1, n);
278 }
279 },
280
Julia Reynolds81afbcd2016-02-09 14:54:08 -0500281 new Test("Is blocked?") {
282 public void run() {
283 Toast.makeText(NotificationTestList.this,
284 "package enabled? " + mNM.areNotificationsEnabled(),
285 Toast.LENGTH_LONG).show();
286 }
287 },
288
Julia Reynoldsef37f282016-02-12 09:11:27 -0500289 new Test("importance?") {
Julia Reynolds81afbcd2016-02-09 14:54:08 -0500290 public void run() {
291 Toast.makeText(NotificationTestList.this,
Julia Reynoldsef37f282016-02-12 09:11:27 -0500292 "importance? " + mNM.getImportance(),
Julia Reynolds81afbcd2016-02-09 14:54:08 -0500293 Toast.LENGTH_LONG).show();
294 }
295 },
296
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400297 new Test("Whens") {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800298 public void run()
299 {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400300 Notification.Builder n = new Notification.Builder(NotificationTestList.this)
301 .setSmallIcon(R.drawable.icon1)
302 .setContentTitle(name)
303 .setOngoing(true);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800304
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400305 mNM.notify(1, n.setContentTitle("(453) 123-2328")
306 .setWhen(System.currentTimeMillis()-(1000*60*60*24))
307 .build());
Joe Onoratoddf680b2010-09-26 13:59:40 -0700308
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400309 mNM.notify(1, n.setContentTitle("Mark Willem, Me (2)")
310 .setWhen(System.currentTimeMillis())
311 .build());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800312
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400313 mNM.notify(1, n.setContentTitle("Sophia Winterlanden")
314 .setWhen(System.currentTimeMillis() + (1000 * 60 * 60 * 24))
315 .build());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800316 }
317 },
318
Joe Onorato005847b2010-06-04 16:08:02 -0400319 new Test("Bad Icon #1 (when=create)") {
Joe Onorato871bdb92010-05-24 18:36:53 -0400320 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400321 Notification n = new Notification.Builder(NotificationTestList.this)
322 .setSmallIcon(R.layout.chrono_notification /* not an icon */)
323 .setWhen(mActivityCreateTime)
324 .setContentTitle("Persistent #1")
325 .setContentText("This is the same notification!!")
326 .setContentIntent(makeIntent())
327 .build();
Joe Onorato005847b2010-06-04 16:08:02 -0400328 mNM.notify(1, n);
Joe Onorato871bdb92010-05-24 18:36:53 -0400329 }
330 },
331
Joe Onorato005847b2010-06-04 16:08:02 -0400332 new Test("Bad Icon #1 (when=now)") {
333 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400334 Notification n = new Notification.Builder(NotificationTestList.this)
335 .setSmallIcon(R.layout.chrono_notification /* not an icon */)
336 .setWhen(System.currentTimeMillis())
337 .setContentTitle("Persistent #1")
338 .setContentText("This is the same notification!!")
339 .setContentIntent(makeIntent())
340 .build();
Joe Onorato005847b2010-06-04 16:08:02 -0400341 mNM.notify(1, n);
Joe Onorato68065e02010-02-03 20:21:41 -0800342 }
343 },
344
Daniel Sandlere40451a2011-02-03 14:51:35 -0500345 new Test("Null Icon #1 (when=now)") {
346 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400347 Notification n = new Notification.Builder(NotificationTestList.this)
348 .setSmallIcon(0)
349 .setWhen(System.currentTimeMillis())
350 .setContentTitle("Persistent #1")
351 .setContentText("This is the same notification!!")
352 .setContentIntent(makeIntent())
353 .build();
Daniel Sandlere40451a2011-02-03 14:51:35 -0500354 mNM.notify(1, n);
355 }
356 },
357
Joe Onorato005847b2010-06-04 16:08:02 -0400358 new Test("Bad resource #1 (when=create)") {
359 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400360 Notification n = new Notification.Builder(NotificationTestList.this)
361 .setSmallIcon(R.drawable.icon2)
362 .setWhen(mActivityCreateTime)
363 .setContentTitle("Persistent #1")
364 .setContentText("This is the same notification!!")
365 .setContentIntent(makeIntent())
366 .build();
Joe Onorato005847b2010-06-04 16:08:02 -0400367 n.contentView.setInt(1 /*bogus*/, "bogus method", 666);
368 mNM.notify(1, n);
369 }
370 },
371
372 new Test("Bad resource #1 (when=now)") {
373 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400374 Notification n = new Notification.Builder(NotificationTestList.this)
375 .setSmallIcon(R.drawable.icon2)
376 .setWhen(System.currentTimeMillis())
377 .setContentTitle("Persistent #1")
378 .setContentText("This is the same notification!!")
379 .setContentIntent(makeIntent())
380 .build();
Joe Onorato005847b2010-06-04 16:08:02 -0400381 n.contentView.setInt(1 /*bogus*/, "bogus method", 666);
382 mNM.notify(1, n);
383 }
384 },
385
Joe Onoratoc83bb732010-01-19 16:32:22 -0800386 new Test("Times") {
387 public void run()
388 {
389 long now = System.currentTimeMillis();
390
391 timeNotification(7, "24 hours from now", now+(1000*60*60*24));
392 timeNotification(6, "12:01:00 from now", now+(1000*60*60*12)+(60*1000));
393 timeNotification(5, "12 hours from now", now+(1000*60*60*12));
394 timeNotification(4, "now", now);
395 timeNotification(3, "11:59:00 ago", now-((1000*60*60*12)-(60*1000)));
396 timeNotification(2, "12 hours ago", now-(1000*60*60*12));
397 timeNotification(1, "24 hours ago", now-(1000*60*60*24));
398 }
399 },
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800400 new StateStress("Stress - Ongoing / Latest", 100, 100, new Runnable[] {
401 new Runnable() {
402 public void run() {
403 Log.d(TAG, "Stress - Ongoing/Latest 0");
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400404 Notification n = new Notification.Builder(NotificationTestList.this)
405 .setSmallIcon(R.drawable.icon3)
406 .setWhen(System.currentTimeMillis())
407 .setContentTitle("Stress - Ongoing")
408 .setContentText("Notify me!!!")
409 .setOngoing(true)
410 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800411 mNM.notify(1, n);
412 }
413 },
414 new Runnable() {
415 public void run() {
416 Log.d(TAG, "Stress - Ongoing/Latest 1");
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400417 Notification n = new Notification.Builder(NotificationTestList.this)
418 .setSmallIcon(R.drawable.icon4)
419 .setWhen(System.currentTimeMillis())
420 .setContentTitle("Stress - Latest")
421 .setContentText("Notify me!!!")
422 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800423 mNM.notify(1, n);
424 }
425 }
426 }),
427
428 new Test("Long") {
429 public void run()
430 {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400431 Notification n = new Notification.Builder(NotificationTestList.this)
432 .setSmallIcon(R.drawable.icon1)
433 .setContentTitle(name)
434 .setDefaults(Notification.DEFAULT_SOUND)
435 .setVibrate(new long[] {
436 300, 400, 300, 400, 300, 400, 300, 400, 300, 400, 300, 400,
437 300, 400, 300, 400, 300, 400, 300, 400, 300, 400, 300, 400,
438 300, 400, 300, 400, 300, 400, 300, 400, 300, 400, 300, 400 })
439 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800440 mNM.notify(1, n);
441 }
442 },
443
Daniel Sandler373a9982010-11-30 12:03:59 -0500444 new Test("Progress #1") {
445 public void run() {
446 final boolean PROGRESS_UPDATES_WHEN = true;
447 if (!mProgressDone) return;
448 mProgressDone = false;
449 Thread t = new Thread() {
450 public void run() {
451 int x = 0;
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400452 final Notification.Builder n = new Notification.Builder(NotificationTestList.this)
453 .setSmallIcon(R.drawable.icon1)
454 .setContentTitle(name)
455 .setOngoing(true);
456
Daniel Sandler373a9982010-11-30 12:03:59 -0500457 while (!mProgressDone) {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400458 n.setWhen(PROGRESS_UPDATES_WHEN
Daniel Sandler373a9982010-11-30 12:03:59 -0500459 ? System.currentTimeMillis()
460 : mActivityCreateTime);
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400461 n.setProgress(100, x, false);
462 n.setContentText("Progress: " + x + "%");
Daniel Sandler373a9982010-11-30 12:03:59 -0500463
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400464 mNM.notify(500, n.build());
Daniel Sandler373a9982010-11-30 12:03:59 -0500465 x = (x + 7) % 100;
466
467 try {
468 Thread.sleep(1000);
469 } catch (InterruptedException e) {
470 break;
471 }
472 }
473 }
474 };
475 t.start();
476 }
477 },
478
479 new Test("Stop Progress") {
480 public void run() {
481 mProgressDone = true;
482 mNM.cancel(500);
483 }
484 },
485
The Android Open Source Project10592532009-03-18 17:39:46 -0700486 new Test("Blue Lights") {
487 public void run()
488 {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400489 Notification n = new Notification.Builder(NotificationTestList.this)
490 .setSmallIcon(R.drawable.icon2)
491 .setContentTitle(name)
492 .setLights(0xff0000ff, 1, 0)
493 .setDefaults(Notification.DEFAULT_LIGHTS)
494 .build();
The Android Open Source Project10592532009-03-18 17:39:46 -0700495 mNM.notify(1, n);
496 }
497 },
498
499 new Test("Red Lights") {
500 public void run()
501 {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400502 Notification n = new Notification.Builder(NotificationTestList.this)
503 .setSmallIcon(R.drawable.icon2)
504 .setContentTitle(name)
505 .setLights(0xffff0000, 1, 0)
506 .setDefaults(Notification.DEFAULT_LIGHTS)
507 .build();
The Android Open Source Project10592532009-03-18 17:39:46 -0700508 mNM.notify(1, n);
509 }
510 },
511
512 new Test("Yellow Lights") {
513 public void run()
514 {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400515 Notification n = new Notification.Builder(NotificationTestList.this)
516 .setSmallIcon(R.drawable.icon2)
517 .setContentTitle(name)
518 .setLights(0xffffff00, 1, 0)
519 .setDefaults(Notification.DEFAULT_LIGHTS)
520 .build();
Mattias Östergrenb0fbe292010-03-05 09:44:15 +0100521 mNM.notify(1, n);
522 }
523 },
524
525 new Test("Lights off") {
526 public void run()
527 {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400528 Notification n = new Notification.Builder(NotificationTestList.this)
529 .setSmallIcon(R.drawable.icon2)
530 .setContentTitle(name)
531 .setLights(0x00000000, 0, 0)
532 .setDefaults(Notification.DEFAULT_LIGHTS)
533 .build();
The Android Open Source Project10592532009-03-18 17:39:46 -0700534 mNM.notify(1, n);
535 }
536 },
537
538 new Test("Blue Blinking Slow") {
539 public void run()
540 {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400541 Notification n = new Notification.Builder(NotificationTestList.this)
542 .setSmallIcon(R.drawable.icon2)
543 .setContentTitle(name)
544 .setLights(0xff0000ff, 1300, 1300)
545 .setDefaults(Notification.DEFAULT_LIGHTS)
546 .build();
The Android Open Source Project10592532009-03-18 17:39:46 -0700547 mNM.notify(1, n);
548 }
549 },
550
551 new Test("Blue Blinking Fast") {
552 public void run()
553 {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400554 Notification n = new Notification.Builder(NotificationTestList.this)
555 .setSmallIcon(R.drawable.icon2)
556 .setContentTitle(name)
557 .setLights(0xff0000ff, 300, 300)
558 .setDefaults(Notification.DEFAULT_LIGHTS)
559 .build();
The Android Open Source Project10592532009-03-18 17:39:46 -0700560 mNM.notify(1, n);
561 }
562 },
563
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800564 new Test("Default All") {
565 public void run()
566 {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400567 Notification n = new Notification.Builder(NotificationTestList.this)
568 .setSmallIcon(R.drawable.icon2)
569 .setContentTitle(name)
570 .setDefaults(Notification.DEFAULT_ALL)
571 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800572 mNM.notify(1, n);
573 }
574 },
575
576 new Test("Default All, once") {
577 public void run()
578 {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400579 Notification n = new Notification.Builder(NotificationTestList.this)
580 .setSmallIcon(R.drawable.icon2)
581 .setContentTitle(name)
582 .setOnlyAlertOnce(true)
583 .setDefaults(Notification.DEFAULT_ALL)
584 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800585 mNM.notify(1, n);
586 }
587 },
588
589 new Test("Resource Sound") {
590 public void run()
591 {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400592 Notification n = new Notification.Builder(NotificationTestList.this)
593 .setSmallIcon(R.drawable.stat_sys_phone)
594 .setContentTitle(name)
595 .setSound(Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
596 getPackageName() + "/raw/ringer"))
597 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800598 Log.d(TAG, "n.sound=" + n.sound);
599
600 mNM.notify(1, n);
601 }
602 },
603
604 new Test("Sound and Cancel") {
605 public void run()
606 {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400607 Notification n = new Notification.Builder(NotificationTestList.this)
608 .setSmallIcon(R.drawable.stat_sys_phone)
609 .setContentTitle(name)
610 .setSound(Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
611 getPackageName() + "/raw/ringer"))
612 .build();
613 Log.d(TAG, "n.sound=" + n.sound);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800614
615 mNM.notify(1, n);
616 SystemClock.sleep(200);
617 mNM.cancel(1);
618 }
619 },
620
621 new Test("Vibrate") {
622 public void run()
623 {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400624 Notification n = new Notification.Builder(NotificationTestList.this)
625 .setSmallIcon(R.drawable.stat_sys_phone)
626 .setContentTitle(name)
627 .setVibrate(new long[]{0, 700, 500, 1000})
628 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800629
630 mNM.notify(1, n);
631 }
632 },
633
634 new Test("Vibrate and cancel") {
635 public void run()
636 {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400637 Notification n = new Notification.Builder(NotificationTestList.this)
638 .setSmallIcon(R.drawable.stat_sys_phone)
639 .setContentTitle(name)
640 .setVibrate(new long[]{0, 700, 500, 1000})
641 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800642
643 mNM.notify(1, n);
644 SystemClock.sleep(500);
645 mNM.cancel(1);
646 }
647 },
648
649 new Test("Vibrate pattern") {
650 public void run()
651 {
652 mVibrator.vibrate(new long[] { 250, 1000, 500, 2000 }, -1);
653 }
654 },
655
656 new Test("Vibrate pattern repeating") {
657 public void run()
658 {
659 mVibrator.vibrate(new long[] { 250, 1000, 500 }, 1);
660 }
661 },
662
663 new Test("Vibrate 3s") {
664 public void run()
665 {
666 mVibrator.vibrate(3000);
667 }
668 },
669
670 new Test("Vibrate 100s") {
671 public void run()
672 {
673 mVibrator.vibrate(100000);
674 }
675 },
676
677 new Test("Vibrate off") {
678 public void run()
679 {
680 mVibrator.cancel();
681 }
682 },
683
684 new Test("Cancel #1") {
685 public void run() {
686 mNM.cancel(1);
687 }
688 },
689
690 new Test("Cancel #1 in 3 sec") {
691 public void run() {
692 mHandler.postDelayed(new Runnable() {
693 public void run() {
694 Log.d(TAG, "Cancelling now...");
695 mNM.cancel(1);
696 }
697 }, 3000);
698 }
699 },
700
701 new Test("Cancel #2") {
702 public void run() {
703 mNM.cancel(2);
704 }
705 },
706
707 new Test("Persistent #1") {
708 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400709 Notification n = new Notification.Builder(NotificationTestList.this)
710 .setSmallIcon(R.drawable.icon1)
711 .setWhen(mActivityCreateTime)
712 .setContentTitle(name)
713 .setContentText("This is a notification!!!")
714 .setContentIntent(makeIntent())
715 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800716 mNM.notify(1, n);
717 }
718 },
719
720 new Test("Persistent #1 in 3 sec") {
721 public void run() {
722 mHandler.postDelayed(new Runnable() {
723 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400724 String message = " "
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800725 + "tick tock tick tock\n\nSometimes notifications can "
726 + "be really long and wrap to more than one line.\n"
727 + "Sometimes."
728 + "Ohandwhathappensifwehaveonereallylongstringarewesure"
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400729 + "thatwesegmentitcorrectly?\n";
730 Notification n = new Notification.Builder(NotificationTestList.this)
731 .setSmallIcon(R.drawable.icon1)
732 .setContentTitle(name)
733 .setContentText("This is still a notification!!!")
734 .setContentIntent(makeIntent())
735 .setStyle(new Notification.BigTextStyle().bigText(message))
736 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800737 mNM.notify(1, n);
738 }
739 }, 3000);
740 }
741 },
742
743 new Test("Persistent #2") {
744 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400745 Notification n = new Notification.Builder(NotificationTestList.this)
746 .setSmallIcon(R.drawable.icon1)
747 .setWhen(mActivityCreateTime)
748 .setContentTitle(name)
749 .setContentText("This is a notification!!!")
750 .setContentIntent(makeIntent())
751 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800752 mNM.notify(2, n);
753 }
754 },
755
Joe Onorato68065e02010-02-03 20:21:41 -0800756 new Test("Persistent #3") {
757 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400758 Notification n = new Notification.Builder(NotificationTestList.this)
759 .setSmallIcon(R.drawable.icon1)
760 .setWhen(mActivityCreateTime)
761 .setContentTitle(name)
762 .setContentText("This is a notification!!!")
763 .setContentIntent(makeIntent())
764 .build();
Joe Onorato68065e02010-02-03 20:21:41 -0800765 mNM.notify(3, n);
766 }
767 },
768
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800769 new Test("Persistent #2 Vibrate") {
770 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400771 Notification n = new Notification.Builder(NotificationTestList.this)
772 .setSmallIcon(R.drawable.icon1)
773 .setWhen(mActivityCreateTime)
774 .setContentTitle(name)
775 .setContentText("This is a notification!!!")
776 .setContentIntent(makeIntent())
777 .setDefaults(Notification.DEFAULT_VIBRATE)
778 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800779 mNM.notify(2, n);
780 }
781 },
782
Joe Onoratod2b1f002010-06-04 10:42:41 -0700783 new Test("Persistent #1 - different icon") {
784 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400785 Notification n = new Notification.Builder(NotificationTestList.this)
786 .setSmallIcon(R.drawable.icon2)
787 .setWhen(mActivityCreateTime)
788 .setContentTitle(name)
789 .setContentText("This is a notification!!!")
790 .setContentIntent(makeIntent())
791 .build();
Joe Onoratod2b1f002010-06-04 10:42:41 -0700792 mNM.notify(1, n);
793 }
794 },
795
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800796 new Test("Chronometer Start") {
797 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400798 Notification n = new Notification.Builder(NotificationTestList.this)
799 .setSmallIcon(R.drawable.icon1)
800 .setWhen(System.currentTimeMillis())
801 .setContentTitle(name)
802 .setContentIntent(makeIntent())
803 .setOngoing(true)
804 .setUsesChronometer(true)
805 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800806 mNM.notify(2, n);
807 }
808 },
809
810 new Test("Chronometer Stop") {
811 public void run() {
812 mHandler.postDelayed(new Runnable() {
813 public void run() {
814 Log.d(TAG, "Chronometer Stop");
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400815 Notification n = new Notification.Builder(NotificationTestList.this)
816 .setSmallIcon(R.drawable.icon1)
817 .setWhen(System.currentTimeMillis())
818 .setContentTitle(name)
819 .setContentIntent(makeIntent())
820 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800821 mNM.notify(2, n);
822 }
823 }, 3000);
824 }
825 },
826
827 new Test("Sequential Persistent") {
828 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400829 mNM.notify(1, notificationWithNumbers(name, 1));
830 mNM.notify(2, notificationWithNumbers(name, 2));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800831 }
832 },
833
834 new Test("Replace Persistent") {
835 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400836 mNM.notify(1, notificationWithNumbers(name, 1));
837 mNM.notify(1, notificationWithNumbers(name, 1));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800838 }
839 },
840
841 new Test("Run and Cancel (n=1)") {
842 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400843 mNM.notify(1, notificationWithNumbers(name, 1));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800844 mNM.cancel(1);
845 }
846 },
847
848 new Test("Run an Cancel (n=2)") {
849 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400850 mNM.notify(1, notificationWithNumbers(name, 1));
851 mNM.notify(2, notificationWithNumbers(name, 2));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800852 mNM.cancel(2);
853 }
854 },
855
856 // Repeatedly notify and cancel -- triggers bug #670627
857 new Test("Bug 670627") {
858 public void run() {
859 for (int i = 0; i < 10; i++) {
860 Log.d(TAG, "Add two notifications");
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400861 mNM.notify(1, notificationWithNumbers(name, 1));
862 mNM.notify(2, notificationWithNumbers(name, 2));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800863 Log.d(TAG, "Cancel two notifications");
864 mNM.cancel(1);
865 mNM.cancel(2);
866 }
867 }
868 },
869
870 new Test("Ten Notifications") {
871 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400872 for (int i = 0; i < 10; i++) {
873 Notification n = new Notification.Builder(NotificationTestList.this)
874 .setSmallIcon(kNumberedIconResIDs[i])
875 .setContentTitle("Persistent #" + i)
876 .setContentText("Notify me!!!" + i)
877 .setOngoing(i < 2)
878 .setNumber(i)
879 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800880 mNM.notify((i+1)*10, n);
881 }
882 }
883 },
884
885 new Test("Cancel eight notifications") {
886 public void run() {
887 for (int i = 1; i < 9; i++) {
888 mNM.cancel((i+1)*10);
889 }
890 }
891 },
892
Daniel Sandlerb0cc50d2010-10-26 16:55:56 -0400893 new Test("Cancel the other two notifications") {
894 public void run() {
895 mNM.cancel(10);
896 mNM.cancel(100);
897 }
898 },
899
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800900 new Test("Persistent with numbers 1") {
901 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400902 mNM.notify(1, notificationWithNumbers(name, 1));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800903 }
904 },
905
Joe Onorato6c01a112010-10-04 17:38:47 -0400906 new Test("Persistent with numbers 22") {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800907 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400908 mNM.notify(1, notificationWithNumbers(name, 22));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800909 }
910 },
911
912 new Test("Persistent with numbers 333") {
913 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400914 mNM.notify(1, notificationWithNumbers(name, 333));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800915 }
916 },
917
918 new Test("Persistent with numbers 4444") {
919 public void run() {
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400920 mNM.notify(1, notificationWithNumbers(name, 4444));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800921 }
922 },
923
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500924 new Test("PRIORITY_HIGH") {
Daniel Sandlere40451a2011-02-03 14:51:35 -0500925 public void run() {
926 Notification n = new Notification.Builder(NotificationTestList.this)
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500927 .setSmallIcon(R.drawable.notification5)
928 .setContentTitle("High priority")
Daniel Sandlere40451a2011-02-03 14:51:35 -0500929 .setContentText("This should appear before all others")
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500930 .setPriority(Notification.PRIORITY_HIGH)
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400931 .build();
Daniel Sandlere40451a2011-02-03 14:51:35 -0500932
933 int[] idOut = new int[1];
934 try {
935 INotificationManager directLine = mNM.getService();
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500936 directLine.enqueueNotificationWithTag(
937 getPackageName(),
Dianne Hackbornf265ea92013-01-31 15:00:51 -0800938 getPackageName(),
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500939 null,
940 100,
941 n,
Dianne Hackborn41203752012-08-31 14:05:51 -0700942 idOut,
943 UserHandle.myUserId());
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500944 } catch (android.os.RemoteException ex) {
945 // oh well
946 }
947 }
948 },
949
950 new Test("PRIORITY_MAX") {
951 public void run() {
952 Notification n = new Notification.Builder(NotificationTestList.this)
953 .setSmallIcon(R.drawable.notification9)
954 .setContentTitle("MAX priority")
955 .setContentText("This might appear as an intruder alert")
956 .setPriority(Notification.PRIORITY_MAX)
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400957 .build();
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500958
959 int[] idOut = new int[1];
960 try {
961 INotificationManager directLine = mNM.getService();
962 directLine.enqueueNotificationWithTag(
963 getPackageName(),
Dianne Hackbornf265ea92013-01-31 15:00:51 -0800964 getPackageName(),
965 null,
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500966 200,
967 n,
Dianne Hackborn41203752012-08-31 14:05:51 -0700968 idOut,
969 UserHandle.myUserId());
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500970 } catch (android.os.RemoteException ex) {
971 // oh well
972 }
973 }
974 },
975
976 new Test("PRIORITY_MIN") {
977 public void run() {
978 Notification n = new Notification.Builder(NotificationTestList.this)
979 .setSmallIcon(R.drawable.notification0)
980 .setContentTitle("MIN priority")
981 .setContentText("You should not see this")
982 .setPriority(Notification.PRIORITY_MIN)
Chris Wren1ce4b6d2015-06-11 10:19:43 -0400983 .build();
Daniel Sandler2561b0b2012-02-13 21:04:12 -0500984
985 int[] idOut = new int[1];
986 try {
987 INotificationManager directLine = mNM.getService();
988 directLine.enqueueNotificationWithTag(
Daniel Sandlere40451a2011-02-03 14:51:35 -0500989 getPackageName(),
Dianne Hackbornf265ea92013-01-31 15:00:51 -0800990 getPackageName(),
991 null,
Daniel Sandlere40451a2011-02-03 14:51:35 -0500992 1,
Daniel Sandlere40451a2011-02-03 14:51:35 -0500993 n,
Dianne Hackborn41203752012-08-31 14:05:51 -0700994 idOut,
995 UserHandle.myUserId());
Daniel Sandlere40451a2011-02-03 14:51:35 -0500996 } catch (android.os.RemoteException ex) {
997 // oh well
998 }
999 }
1000 },
1001
The Android Open Source Project10592532009-03-18 17:39:46 -07001002 new Test("Crash") {
1003 public void run()
1004 {
1005 PowerManager.WakeLock wl
Christian Mehlmaueref367522010-05-31 23:08:30 +02001006 = ((PowerManager)NotificationTestList.this.getSystemService(Context.POWER_SERVICE))
The Android Open Source Project10592532009-03-18 17:39:46 -07001007 .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "crasher");
1008 wl.acquire();
1009 mHandler.postDelayed(new Runnable() {
1010 public void run() {
1011 throw new RuntimeException("Die!");
1012 }
1013 }, 10000);
1014
1015 }
1016 },
1017
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001018 };
1019
Chris Wren1ce4b6d2015-06-11 10:19:43 -04001020 private Notification notificationWithNumbers(String name, int num) {
1021 Notification n = new Notification.Builder(NotificationTestList.this)
1022 .setSmallIcon((num >= 0 && num < kNumberedIconResIDs.length)
1023 ? kNumberedIconResIDs[num]
1024 : kUnnumberedIconResID)
1025 .setContentTitle(name)
1026 .setContentText("Number=" + num)
1027 .setNumber(num)
1028 .build();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001029 return n;
1030 }
1031
1032 private PendingIntent makeIntent() {
1033 Intent intent = new Intent(Intent.ACTION_MAIN);
Joe Onorato0e26dff2010-05-24 16:17:02 -04001034 intent.addCategory(Intent.CATEGORY_HOME);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001035 return PendingIntent.getActivity(this, 0, intent, 0);
1036 }
1037
Joe Onorato184498c2010-10-08 17:57:18 -04001038 private PendingIntent makeIntent2() {
1039 Intent intent = new Intent(this, StatusBarTest.class);
1040 return PendingIntent.getActivity(this, 0, intent, 0);
1041 }
1042
1043
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001044 class StateStress extends Test {
1045 StateStress(String name, int pause, int iterations, Runnable[] tasks) {
1046 super(name);
1047 mPause = pause;
1048 mTasks = tasks;
1049 mIteration = iterations;
1050 }
1051 Runnable[] mTasks;
1052 int mNext;
1053 int mIteration;
1054 long mPause;
1055 Runnable mRunnable = new Runnable() {
1056 public void run() {
1057 mTasks[mNext].run();
1058 mNext++;
1059 if (mNext >= mTasks.length) {
1060 mNext = 0;
1061 mIteration--;
1062 if (mIteration <= 0) {
1063 return;
1064 }
1065 }
1066 mHandler.postDelayed(mRunnable, mPause);
1067 }
1068 };
1069 public void run() {
1070 mNext = 0;
1071 mHandler.postDelayed(mRunnable, mPause);
1072 }
1073 }
Joe Onoratoc83bb732010-01-19 16:32:22 -08001074
1075 void timeNotification(int n, String label, long time) {
Chris Wren1ce4b6d2015-06-11 10:19:43 -04001076 mNM.notify(n, new Notification.Builder(NotificationTestList.this)
1077 .setSmallIcon(R.drawable.ic_statusbar_missedcall)
1078 .setWhen(time)
1079 .setContentTitle(label)
1080 .setContentText(new java.util.Date(time).toString())
1081 .build());
Joe Onoratoc83bb732010-01-19 16:32:22 -08001082
1083 }
Joe Onoratoef1e7762010-09-17 18:38:38 -04001084
1085 Bitmap loadBitmap(int resId) {
1086 BitmapDrawable bd = (BitmapDrawable)getResources().getDrawable(resId);
1087 return Bitmap.createBitmap(bd.getBitmap());
1088 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001089}
1090