// 在Android进行通知处理,首先需要重系统哪里获得通知管理器NotificationManager,它是一个系统Service。 NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); // 创建一个PendingIntent,和Intent类似,不同的是由于不是马上调用,需要在下拉状态条出发的activity,所以采用的是PendingIntent,即点击Notification跳转启动到哪个Activity PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0); // 下面需兼容Android 2.x版本是的处理方式 // Notification notify1 = new Notification(R.drawable.message, // "TickerText:" + "您有新短消息,请注意查收!", System.currentTimeMillis()); Notification notify1 = new Notification(); notify1.icon = R.drawable.asd; notify1.tickerText = "TickerText:您有新短消息,请注意查收!"; notify1.when = System.currentTimeMillis(); notify1.when = System.currentTimeMillis(); //已过时,弃用 notify1.setLatestEventInfo(this, "Notification Title", "This is the notification message", pendingIntent); notify1.number = 1; notify1.flags |= Notification.FLAG_AUTO_CANCEL; // FLAG_AUTO_CANCEL表明当通知被用户点击时,通知将被清除。 // 通过通知管理器来发起通知。如果id不同,则每click,在statu那里增加一个提示 manager.notify(NOTIFICATION_FLAG, notify1);