//传入notifycation对象的作用是,当将服务设为前台服务后,会在状态栏显示一条通知

public void showCXBRunning() {

NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

Notification builder = new Notification.Builder(this).setTicker("").setSmallIcon(R.drawable.ic_launcher).build();

//id 不能为0

startForeground(1, builder);

}

https://blog.csdn.net/sinat_35159441/article/details/68925922

https://blog.csdn.net/marswin89/article/details/50890708

关于设置前台Service进程的误区

https://blog.csdn.net/joye123/article/details/72654885

Android开发之如何保证Service不被杀掉(前台服务)

https://www.cnblogs.com/MouTou/p/5607423.html

创建两个服务,一个去关闭通知

https://blog.csdn.net/wxx614817/article/details/50669420

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐