源码资源 ) 实现了一个前台 Service , 在通知栏 , 存在一个通知 ;
二、 设置 startForeground id 参数为 0
----
在开启 Service 时 , 调用的 startForeground...(0, notification) 方法中 , 传入的第一个参数 id 如果设置为 0 , 此时就不会弹出通知栏 , 但是同样 , 进程会变成后台进程 ;
启动后没有通知 ,
按下 Home 键后查询..., 绑定相同的 id , 后一个服务开启后马上关闭 , 即可将通知栏移除 ;
startForeground(10, new Notification());..., 会在通知栏显示该前台服务
// 8.0 以上该用法报错
startForeground(10, new Notification());...设置 Activity 亲和性
让该界面在一个独立的任务栈中 , 不要与本应用的其它任务栈放在一起
避免解除锁屏后 , 关闭 1 像素界面 , 将整个任务栈都唤醒