Notification的使用(待完善)-〉添加点击取消,显示优化

PendingIntent intent5 = PendingIntent.getActivity(this, LATESTNEWSNOTIFICATIONID, new Intent(
                    this, NotificationActivity.class), PendingIntent.FLAG_ONE_SHOT);
            NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
            builder.setContentTitle("这是通知的title..");
            builder.setContentText("这是内容文本....");
            builder.setSmallIcon(R.drawable.ic_launcher);// 小图片
            builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));// 大图标
            builder.setWhen(System.currentTimeMillis());// 设置通知发布时间
            builder.setContentIntent(intent5);

            Notification notification = builder.build();

            notificationManager.notify(LATESTNEWSNOTIFICATIONID, notification);

原文地址:https://www.cnblogs.com/mada0/p/4830018.html