What Changed in Android 15 and Why Your App May Crash
Android 15 (API 35) tightens the screws on background work harder than any release since Doze. If you’re targeting API 35 and your app relies on long-running services, you’re already on borrowed time — Google’s compatibility shims expire fast. Android 15 foreground services keep the type declarations and per-type permissions that Android 14 made mandatory, and add new runtime limits: a total of 6 hours in a 24-hour period for dataSync and, separately, for the new mediaProcessing type, fewer service types that BOOT_COMPLETED receivers may launch, and a visible-overlay requirement for background starts that rely on SYSTEM_ALERT_WINDOW.
However, the new restrictions aren’t arbitrary. Most apps using foreground services for periodic sync, expedited jobs, or “keep-alive” patterns were never the right tool for the job. WorkManager and the new user-initiated APIs cover the legitimate cases more cleanly. Here’s a practical migration playbook.
Required foregroundServiceType declarations
Apps that target Android 14 (API 34) or higher must declare an android:foregroundServiceType attribute on the <service> element of every service they start as a foreground service, and the requirement still applies when you move to API 35. The valid values include mediaPlayback, location, dataSync, connectedDevice, mediaProjection, camera, microphone, health, remoteMessaging, shortService, specialUse, and systemExempted.
Android 14 also requires a type-specific permission, such as FOREGROUND_SERVICE_DATA_SYNC or FOREGROUND_SERVICE_LOCATION, for every type except shortService. Declaring the type without the corresponding permission throws SecurityException on startup. Lint catches most of these mismatches, but only if you actually run lint in CI.
New timeouts and launch restrictions in Android 15
For apps that target API 35, all of an app’s dataSync services together may run for 6 hours in a 24-hour period, and the timer resets when the user brings the app to the foreground. At the limit, the system calls the new Service.onTimeout(int, int); the service then has a few seconds to call stopSelf() before the system throws a fatal RemoteServiceException, and further dataSync starts throw ForegroundServiceStartNotAllowedException until the timer resets. The new mediaProcessing type, meant for work like transcoding, has its own separate 6-hour budget.
Two launch paths are narrower too. BOOT_COMPLETED receivers can no longer launch dataSync, camera, mediaPlayback, phoneCall, or mediaProjection foreground services (microphone has been blocked there since Android 14), and the attempt throws the same exception. And holding SYSTEM_ALERT_WINDOW now exempts a background start only while the app has a visible TYPE_APPLICATION_OVERLAY window.
// AndroidManifest.xml additions
// <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
// <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
// <service
// android:name=".sync.UploadService"
// android:foregroundServiceType="dataSync"
// android:exported="false" />
class UploadService : Service() {
override fun onStartCommand(
intent: Intent?, flags: Int, startId: Int
): Int {
val notification = buildNotification()
try {
ServiceCompat.startForeground(
this,
NOTIFICATION_ID,
notification,
ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
)
} catch (e: ForegroundServiceStartNotAllowedException) {
// Fall back to WorkManager — start not allowed (e.g. dataSync time limit used up)
UploadWorker.enqueueOneShot(applicationContext)
stopSelf(startId)
return START_NOT_STICKY
}
scope.launch { performUpload(startId) }
return START_REDELIVER_INTENT
}
override fun onBind(intent: Intent?): IBinder? = null
private fun buildNotification(): Notification {
val channelId = ensureChannel()
return NotificationCompat.Builder(this, channelId)
.setContentTitle(getString(R.string.uploading))
.setSmallIcon(R.drawable.ic_upload)
.setOngoing(true)
.setForegroundServiceBehavior(
NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE
)
.build()
}
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
companion object {
private const val NOTIFICATION_ID = 4711
fun start(context: Context, uri: Uri) {
val intent = Intent(context, UploadService::class.java)
.putExtra("uri", uri)
ContextCompat.startForegroundService(context, intent)
}
}
}
When to migrate to WorkManager instead
Many “foreground service” patterns were never user-visible work. Periodic sync, opportunistic uploads, expedited push handling — these all belong in WorkManager. Specifically, expedited WorkRequest instances with OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST handle most “I need this within a minute” cases without needing a foreground service at all.
Conversely, genuinely long-running, user-visible work — playing a podcast, recording a workout, navigating a route — still belongs in a foreground service with the appropriate type. The dividing line is whether the user expects to see ongoing progress in their notification shade. For a deeper view on background scheduling, see my earlier post on Android baseline profiles, which covers cold-start patterns that often interact with these services.
Real migration examples
For a Spotify-style media app, the answer is unchanged: declare mediaPlayback, attach a MediaSession, and you’re compliant. The platform treats media as a first-class long-running case. Just make sure the service is started in response to a user play action, not auto-resume on launch.
For a Strava-style activity tracker, declare location with the matching permission and start the service from the explicit “Start workout” button. Auto-starting on app launch — for example to “warm up” the GPS — is now denied. Push that warmup to the foreground UI itself.
For a file uploader, the cleanest pattern is a one-shot expedited WorkRequest per upload, with a setExpedited call. If the upload genuinely needs to run for more than 10 minutes, the worker can call setForeground() (or setForegroundAsync()) with a ForegroundInfo of type dataSync to become a long-running worker. WorkManager then runs it in a foreground service, so foreground-service rules apply: the call throws an IllegalStateException if the process is subject to foreground service restrictions, and for apps targeting API 35 the run counts against the 6-hour dataSync budget. For uploads the user starts explicitly, a user-initiated data transfer job (Android 14+) is the documented alternative.
Mitigating ForegroundServiceStartNotAllowedException
This is the exception you’ll see most often during migration. The fix is rarely “wrap in try/catch and retry” — that just defers the crash. Instead, audit every code path that calls startForegroundService and ask whether the user just did something that justifies it.
Additionally, the shortService type is a useful escape hatch for genuinely short tasks (under 3 minutes) that need foreground priority. It carries fewer restrictions than dataSync but cannot run indefinitely. Use it for tasks like “finish this single upload after the app is backgrounded” rather than persistent sync loops. Architecture-wise, this pairs well with patterns I’ve covered in shared ViewModel architectures.
Debugging with adb shell dumpsys
The single most useful command during migration is adb shell dumpsys activity services <package>. It dumps every active service, its declared type, the trigger source, and the elapsed runtime. Specifically, look at the fgRequired and fgServiceType fields — mismatches between manifest and runtime always cause crashes.
Furthermore, adb logcat -s ActivityManager surfaces the platform’s reasoning when it denies a service start. The error messages now name the offending policy explicitly, which is a huge improvement over Android 14. The official Android 15 behavior changes documentation is the canonical reference.
Testing the new restrictions
On a device running Android 15, you can enable the new enforcement for a debuggable build before it targets API 35: adb shell am compat enable FGS_INTRODUCE_TIME_LIMITS <package> turns on the dataSync and mediaProcessing timeouts, and FGS_BOOT_COMPLETED_RESTRICTIONS and FGS_SAW_RESTRICTIONS do the same for the boot and overlay rules. To reach onTimeout() without waiting six hours, shorten the limit with adb shell device_config put activity_manager data_sync_fgs_timeout_duration <milliseconds>. Furthermore, exercise every push-handler, broadcast receiver, and alarm trigger path — these are the cold-start scenarios that bite hardest.
In conclusion, Android 15 foreground services build on Android 14’s mandatory type declarations and paired permissions with new runtime limits: separate 6-hour budgets per 24 hours for dataSync and mediaProcessing, fewer types that BOOT_COMPLETED receivers can launch, and a visible-overlay requirement for SYSTEM_ALERT_WINDOW background starts. The migration is mostly an audit exercise: identify each service, classify its purpose, and route it to the right primitive — type-specific foreground service for user-visible long work, expedited WorkManager for everything else. Apps that complete this audit cleanly land on a more predictable, battery-friendly platform; apps that don’t will hit these exceptions and timeouts once they target API 35.