1.生成NotificationManager
NotificationManager nm ;
if(nm!=null){
nm = new NotificationManger(context.notification_service);
}
2.生成Notification
Notification notification = new Notification(R.drawable.logo,"标题",System.currentTimeMillis());
3.设置各种属性
如:notification.flags = Notification.FLAG_AUTO_CANCEL;
4. 设置打开通知后要跳转的activity
Intent intent = new Intent(this,mainActivity.class);
PendingIntent pin = PendingIntent.getActivity(context,0,intent,0);
notification.setLatestEventInfo(context,"标题","内容",pin);
5.显示
nm.notify(id,notification);