SIGN IN SIGN UP

Catch ForegroundServiceStartNotAllowedException in stopSelfSafely.

Catch ForegroundServiceStartNotAllowedException when stopSelfSafely()
attempts to set a shutdown notification. On Android 12+, starting a
foreground service may not be allowed from the background, throwing this
exception. Catching it ensures the service can proceed to stop safely
without crashing the application.

Issue: androidx/media#3310
#cherrypick
PiperOrigin-RevId: 949009537
(cherry picked from commit abfcccadeaee42e52c641ea2a5461fea3a96caf6)
B
bachinger committed
b33316303d3ef5ad0ede57cbc9dab6d8ab1e63a6
Parent: 66d8d7a
Committed by Tianyi Feng <tianyifeng@google.com> on 7/16/2026, 4:18:26 PM