调用步骤:
- 调用getSystemService(NOTIFICATION_SERVICE)方法获取系统的 Notification Manager服务
- 通过构造器创建一个Notification对象
- 为Notification设置各种属性
- 通过NotificationManager发送Notification
Notification常用方法
        /*设置large icon*/
        .setLargeIcon(bitmap)
         /*设置small icon*/
        .setSmallIcon()
        /*设置title*/
        .setContentTitle()
        /*设置详细文本*/
        .setContentText()
         /*设置发出通知的时间为发出通知时的系统时间*/
        .setWhen(System.currentTimeMillis())
         /*设置发出通知时在status bar进行提醒*/
        .setTicker("设置状态栏提示文本")
        /*setOngoing(boolean)设为true,notification将无法通过左右滑动的方式清除 * 可用于添加常驻通知,必须调用cancle方法来清除 */
        .setOngoing(true)
         /*设置点击后通知消失*/
        .setAutoCancel(true)
         /*设置通知数量的显示类似于QQ那种,用于同志的合并*/
        .setNumber(2)
         /*点击跳转Activity*/
        .setContentIntent();
示例代码
 imageToast=(Button) findViewById(R.id.imageToast);
        imageToast.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                count++;
                NotificationManager manager =(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
                NotificationCompat.Builder builder = new NotificationCompat.Builder(MainActivity.this);
                builder.setSmallIcon(R.mipmap.ic_launcher);
                builder.setContentTitle("你有"+count+"个新消息");//设置状态栏题目
                builder.setContentText("设置状态栏文本");
                builder.setTicker("设置状态栏提示文本");
                builder.setNumber(2);//设置消息数目
                Notification notification  = builder.build();
                manager.notify(NOTIFICATION_ID,notification);
            }
        });
 
  
  
  
 
 
  
 
 
 