[英]Does service still run in foreground after “show notifications” is un-checked?
我知道要作为前台服务运行,您需要显示一条通知。 我的应用程序将服务作为前台服务运行,并显示一条通知。
但是,如果用户进入“设置”->“应用程序”->“我的应用程序”->,并取消选中“显示通知”,该服务是否将继续作为前台服务运行?
我以为是,它将继续作为前台服务运行。
但是,我最近注意到我的服务被系统杀死,并在logcat中看到了这一点:
杀死2647:com.myapp.myapp:Service / u0a122(adj 15):杀死背景
该服务被杀死,并且它本身没有重新启动。 这是在Android 4.4.2上。 最糟糕的是,没有调用onDestroy,所以我什至无法释放一些唤醒锁。
运行adb shell dumpsys activity services
并检查adb shell dumpsys activity services
的isForeground
标志的值。
* ServiceRecord{e66dea9 u0 com.example.foregroundservice/.ForegroundService}
intent={cmp=com.example.foregroundservice/.ForegroundService}
packageName=com.example.foregroundservice
processName=com.example.foregroundservice:backgroundproc
baseDir=/data/app/com.example.foregroundservice-2/base.apk
dataDir=/data/user/0/com.example.foregroundservice
app=ProcessRecord{254dd51 14363:com.example.foregroundservice:backgroundproc/u0a65}
isForeground=true foregroundId=101 foregroundNoti=Notification(pri=0 contentView=null vibrate=null sound=null tick defaults=0x0 flags=0x40 color=0x00000000 vis=PRIVATE)
createTime=-55s70ms startingBgTimeout=--
lastActivity=-55s70ms restartTime=-55s70ms createdFromFg=true
startRequested=true delayedStop=false stopIfKilled=false callStart=true lastStartId=1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.