草庐IT

StartForeground

全部标签

android - startForeground() 导致 Cordova 出现问题

我在我的cordova应用程序中使用了一项服务,该服务会生成startForegroundonCreate中的通知。如果应用程序通过滑动被杀死并重新启动,则不再触发cordovadevice-ready事件。看来cordova重新启动应用程序时undefinedobject本身。我收到以下错误消息:E/WebConsole(19472):UncaughtTypeError:Object#hasnomethod'exec'atfile:///android_asset/www/src/jsFile.js:31第31行及以下:cordova.exec(function(r){if(call

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

Android - 为服务实现 startForeground?

所以我不确定在哪里/如何实现此方法以使我的服务在前台运行。目前我在另一个Activity中通过以下方式开始我的服务:Intenti=newIntent(context,myService.class);context.startService(i);然后在myServices的onCreate()中尝试startForeground()...?Notificationnotification=newNotification();startForeground(1,notification);所以是的,我有点迷茫,不确定如何实现这一点。 最佳答案

android - 权限拒绝 : startForeground requires android. 权限.FOREGROUND_SERVICE

最近我们突然看到以下一些堆栈跟踪。为什么会这样?这是从应用程序尝试将音频评论服务移动到前台并带有媒体通知和所有内容的时候开始的。java.lang.SecurityException:PermissionDenial:startForegroundfrompid=1824,uid=10479requiresandroid.permission.FOREGROUND_SERVICEatandroid.os.Parcel.createException(Parcel.java:1942)atandroid.os.Parcel.readException(Parcel.java:1910)a