mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-06 11:28:22 +00:00
On Android 14+ (API 34), when a service declares
foregroundServiceType="specialUse" in the manifest it must also pass
FOREGROUND_SERVICE_TYPE_SPECIAL_USE to startForeground() at runtime.
Without this the system rejects the notification with
CannotPostForegroundServiceNotificationException ("Bad notification for
startForeground"), which crashes the service on affected devices such as
the Motorola moto g15 running Android 15.
Use ServiceCompat.startForeground() (from androidx.core) so the type is
forwarded only on API 29+ where the three-argument overload exists, and
FOREGROUND_SERVICE_TYPE_SPECIAL_USE is gated on API 34+.
https://claude.ai/code/session_014KKpPSKZSnFrZf6tmMdCiz