최근에 우리는 갑자기 다음과 같은 몇 가지 스택 추적을보고있었습니다. 왜 그런가요? 앱이 미디어 알림 및 모든 내용으로 오디오 설명 서비스를 포 그라운드로 이동하려고 할 때 발생합니다.
java.lang.SecurityException: Permission Denial: startForeground from pid=1824, uid=10479 requires android.permission.FOREGROUND_SERVICE
at android.os.Parcel.createException(Parcel.java:1942)
at android.os.Parcel.readException(Parcel.java:1910)
at android.os.Parcel.readException(Parcel.java:1860)
at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:5198)
at android.app.Service.startForeground(Service.java:695)
at com.example.app.services.AudioService.setUpMediaNotification(AudioService.java:372)
at com.example.app.services.AudioService.setUpAndStartAudioFeed(AudioService.java:328)
at com.example.app.services.AudioService.onStartCommand(AudioService.java:228)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3667)
at android.app.ActivityThread.access$1600(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ActivityManagerService.enforcePermission(ActivityManagerService.java:9186)
at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked(ActiveServices.java:1189)
at com.android.server.am.ActiveServices.setServiceForegroundLocked(ActiveServices.java:870)
at com.android.server.am.ActivityManagerService.setServiceForeground(ActivityManagerService.java:20434)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:976)
targetSdkVersion
, 우리는 28를 실행하는 장치에서 전경 서비스를 실행할 수있는 권한이 필요하지 않습니다 (28)보다 낮다?