Bootstrap

Android Studio 1-3 Notitfcation 通知 与 双击退出

一、Notitfcation 通知

1、交互式的通知

 //通知管理
                NotificationManager manager1 = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                Notification.Builder builder1 = new Notification.Builder(this);
                builder1.setSmallIcon(R.mipmap.ic_launcher);
                builder1.setContentTitle("这是标题");
                builder1.setContentText("这是内容部分");

                builder1.setPriority(Notification.PRIORITY_MAX);
                builder1.setDefaults(Notification.DEFAULT_ALL);

                //完成之后 自动取消通知
                builder1.setAutoCancel(true);
                //跳转意图
                Intent intent = new Intent(this, MainActivity.class);
                //跳转指向和方式
                PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
                //设置跳转
                builder1.setContentIntent(pendingIntent);

                Notification build1 = builder1.build();
                manager1.notify(1, build1);

2、发送大图或列表通知

 //通知管理
                NotificationManager manager2 = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                Notification.Builder builder2 = new Notification.Builder(this);
                builder2.setSmallIcon(R.mipmap.ic_launcher);
                builder2.setContentTitle("这是标题");
//                builder2.setContentText("这是内容部分");

                builder2.setPriority(Notification.PRIORITY_MAX);
                builder2.setDefaults(Notification.DEFAULT_ALL);

                //大图
                Notification.BigPictureStyle bigPictureStyle = new Notification.BigPictureStyle();
                bigPictureStyle.bigLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_round

悦读

道可道,非常道;名可名,非常名。 无名,天地之始,有名,万物之母。 故常无欲,以观其妙,常有欲,以观其徼。 此两者,同出而异名,同谓之玄,玄之又玄,众妙之门。

;