Version
Media3 pre-release (alpha, beta or RC not in this list)
More version details
Media3 1.11.0 - alpha01
Devices that reproduce the issue
Infinix X6833B run Android in 13/14/16
Samsung SM-A566B run Android in 13/14/16
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Not tested
Reproduction steps
We extended our playback service by your MediaSessionService, and according to the crash stats in Crashlytics, the device states were 100% in the background, we actually instantiate the media controller right after the user starts to playback, but I'm not sure what's going on under the hood.
Expected result
Since we don't have control over starting the service as foreground, I'm wondering does it make sense to catch the exception on the library side, at least to avoid crashing in this case?
Actual result
Caused by android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.free.block.musicum/com.mordo.musicum.playback.PlayService
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
at android.os.Parcel.readParcelableInternal(Parcel.java:4903)
at android.os.Parcel.readParcelable(Parcel.java:4885)
at android.os.Parcel.createExceptionOrNull(Parcel.java:3085)
at android.os.Parcel.createException(Parcel.java:3074)
at android.os.Parcel.readException(Parcel.java:3057)
at android.os.Parcel.readException(Parcel.java:2999)
at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7245)
at android.app.Service.startForeground(Service.java:862)
at androidx.media3.common.util.Util$Api29.startForeground(Util.java:4609)
at androidx.media3.common.util.Util.setForegroundServiceNotification(Util.java:325)
at androidx.media3.session.MediaSessionService.stopSelfSafely(MediaSessionService.java:592)
at androidx.media3.session.MediaSessionService.onStartCommand(MediaSessionService.java:536)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5268)
at android.app.ActivityThread.-$$Nest$mhandleServiceArgs()
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2531)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:8919)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Caused by android.app.StackTrace: Last startServiceCommon() call for this service was made here
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:2191)
at android.app.ContextImpl.startForegroundService(ContextImpl.java:2135)
at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:903)
at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:903)
at androidx.core.content.ContextCompat$Api26Impl.startForegroundService(ContextCompat.java:871)
at androidx.core.content.ContextCompat.startForegroundService(ContextCompat.java:563)
at androidx.media3.session.MediaButtonReceiver.handleIntentAndMaybeStartTheService(MediaButtonReceiver.java:185)
at androidx.media3.session.MediaButtonReceiver.onReceive(MediaButtonReceiver.java:126)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:6032)
at android.app.ActivityThread.-$$Nest$mhandleReceiver()
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:3041)
at android.os.Handler.dispatchMessage(Handler.java:132)
at android.os.Looper.dispatchMessage(Looper.java:358)
at android.os.Looper.loopOnce(Looper.java:288)
at android.os.Looper.loop(Looper.java:392)
at android.app.ActivityThread.main(ActivityThread.java:10346)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:638)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:972)
Media
Nothing particular, just normal audio streaming
Bug Report
Version
Media3 pre-release (alpha, beta or RC not in this list)
More version details
Media3 1.11.0 - alpha01
Devices that reproduce the issue
Infinix X6833B run Android in 13/14/16
Samsung SM-A566B run Android in 13/14/16
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Not tested
Reproduction steps
We extended our playback service by your MediaSessionService, and according to the crash stats in Crashlytics, the device states were 100% in the background, we actually instantiate the media controller right after the user starts to playback, but I'm not sure what's going on under the hood.
Expected result
Since we don't have control over starting the service as foreground, I'm wondering does it make sense to catch the exception on the library side, at least to avoid crashing in this case?
Actual result
Caused by android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.free.block.musicum/com.mordo.musicum.playback.PlayService
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
at android.os.Parcel.readParcelableInternal(Parcel.java:4903)
at android.os.Parcel.readParcelable(Parcel.java:4885)
at android.os.Parcel.createExceptionOrNull(Parcel.java:3085)
at android.os.Parcel.createException(Parcel.java:3074)
at android.os.Parcel.readException(Parcel.java:3057)
at android.os.Parcel.readException(Parcel.java:2999)
at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7245)
at android.app.Service.startForeground(Service.java:862)
at androidx.media3.common.util.Util$Api29.startForeground(Util.java:4609)
at androidx.media3.common.util.Util.setForegroundServiceNotification(Util.java:325)
at androidx.media3.session.MediaSessionService.stopSelfSafely(MediaSessionService.java:592)
at androidx.media3.session.MediaSessionService.onStartCommand(MediaSessionService.java:536)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5268)
at android.app.ActivityThread.-$$Nest$mhandleServiceArgs()
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2531)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:8919)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Caused by android.app.StackTrace: Last startServiceCommon() call for this service was made here
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:2191)
at android.app.ContextImpl.startForegroundService(ContextImpl.java:2135)
at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:903)
at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:903)
at androidx.core.content.ContextCompat$Api26Impl.startForegroundService(ContextCompat.java:871)
at androidx.core.content.ContextCompat.startForegroundService(ContextCompat.java:563)
at androidx.media3.session.MediaButtonReceiver.handleIntentAndMaybeStartTheService(MediaButtonReceiver.java:185)
at androidx.media3.session.MediaButtonReceiver.onReceive(MediaButtonReceiver.java:126)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:6032)
at android.app.ActivityThread.-$$Nest$mhandleReceiver()
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:3041)
at android.os.Handler.dispatchMessage(Handler.java:132)
at android.os.Looper.dispatchMessage(Looper.java:358)
at android.os.Looper.loopOnce(Looper.java:288)
at android.os.Looper.loop(Looper.java:392)
at android.app.ActivityThread.main(ActivityThread.java:10346)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:638)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:972)
Media
Nothing particular, just normal audio streaming
Bug Report
adb bugreportto [email protected] after filing this issue.