1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| String service = NOTIFICATION_SERVICE; nManager = (NotificationManager) this.getSystemService(service);
notification = new Notification();
String tickerText = "状态栏上显示的消息";
long when = System.currentTimeMillis(); notification.icon = R.drawable.icon; notification.tickerText = tickerText; notification.when = when;
notification.ledARGB = 0xff00ff00;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults = Notification.DEFAULT_SOUND;
notification.defaults = Notification.DEFAULT_ALL;
Intent intent = new Intent(this,MainActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(this, "消息的标题","消息的内容", pIntent);
nManager.notify(1, notification);
|