Intentintent=newIntent(MainActivity.this, NotificationActivity.class); PendingIntentpi= PendingIntent.getActivity(MainActivity.this, 0, intent, 0); NotificationManagermanager= (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notificationnotification=newNotificationCompat.Builder(MainActivity.this) .setContentTitle("This is content title") .setContentText("this is content text") .setWhen(System.currentTimeMillis()) .setSmallIcon(R.mipmap.ic_launcher) .setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher)) .setContentIntent(pi) // 设置点击跳转 .setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .setContentText("This is a notification test, this Builder has many func, but do not test all of them ") .setPriority(NotificationCompat.PRIORITY_MAX) .build(); manager.notify(1,notification); //manager.cancel(1); // 同上面autocancel(),取消通知,这样通知点击后才能从通知栏消失