//传入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

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐