jjzjj

startForegroundService

全部标签

java - startForegroundService() 没有调用 startForeground(),但它调用了

我的Android服务中的Context.startForegroundService()没有调用Service.startForeground(),但我不明白为什么会这样。我的应用是做流媒体的,只有当你从前台通知暂停(变成普通通知),然后你把通知滑开,这是为了停止我的服务时,才会出现这个错误。这是调用startForegroundService、startForeground和stopForeground方法的唯一方法:privatevoidconfigureServiceState(longaction){if(action==PlaybackStateCompat.ACTION_

android - Context.startForegroundService() 没有调用 Service.startForeground()

我在AndroidO操作系统上使用Service类。我打算在后台使用Service。Androiddocumentation声明IfyourapptargetsAPIlevel26orhigher,thesystemimposesrestrictionsonusingorcreatingbackgroundservicesunlesstheappitselfisintheforeground.Ifanappneedstocreateaforegroundservice,theappshouldcallstartForegroundService().如果使用startForegroun

android - Context.startForegroundService() 没有调用 Service.startForeground()

我在AndroidO操作系统上使用Service类。我打算在后台使用Service。Androiddocumentation声明IfyourapptargetsAPIlevel26orhigher,thesystemimposesrestrictionsonusingorcreatingbackgroundservicesunlesstheappitselfisintheforeground.Ifanappneedstocreateaforegroundservice,theappshouldcallstartForegroundService().如果使用startForegroun

android - 绑定(bind)服务崩溃并出现 "Context.startForegroundService() did not then call Service.startForeground()"错误

我目前正在开发音频播放应用程序,并且正在使用已启动的绑定(bind)服务在后台播放音乐。我使用以下代码启动并绑定(bind)到服务。valintent=Intent(context,MusicService::class.java)context.startService(intent)context.bindService(intent,serviceConnection,0)播放时提升到前台,音乐暂停时降级。//onAudioPlayservice.startForeground(NOTIFY_ID,notification)//onAudioPauseservice.stopFo
12