Android 通知栏消息
//创建通知管理类
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
//创建通知建设类
Notification.Builder builder = new Notification.Builder(MainActivity.this);
//设置跳转的页面
PendingIntent intent = PendingIntent.getActivity(MainActivity.this,
100, new Intent(MainActivity.this, MainActivity.class),
PendingIntent.FLAG_CANCEL_CURRENT);
//设置通知栏标题
builder.setContentTitle("新邮件");
//设置通知栏内容
builder.setContentText("Android O终于要赶在全日食当日正式与普通消费者见面");
//设置跳转
builder.setContentIntent(intent);
//设置图标
builder.setSmallIcon(R.mipmap.ic_launcher);
//设置
builder.setDefaults(Notification.DEFAULT_ALL);
//创建通知类
Notification notification = builder.build();
//显示在通知栏
manager.notify(0, notification);