1.如果是系统程序 可以配置android:persistent =true
2.非系统的可以在绑定的时候这样
Notification notification = new Notification();
notification.flags = Notification.FLAG_ONGOING_EVENT;
notification.flags |= Notification.FLAG_NO_CLEAR;
notification.flags |= Notification.FLAG_FOREGROUND_SERVICE;
service.startForeground(1, notification);
常驻内存的service
最新推荐文章于 2023-03-10 23:59:15 发布