Background Downloads
By default, downloads run in the application process and are not equivalent to Android system-managed background downloads. But, let’s also understand how to configure optional foreground-service support so long-running offline map downloads can continue when the application moves to the background.
To continue long-running transfers after the app enters the background, the host must implement DownloadForegroundHook and provide notification, Service, and Android-version compatibility logic.
Register the hook:
At minimum, declare the following in the manifest:
The hook's start/stop operations must be idempotent. isForegroundEstablished() must wait until the Service has successfully called Android startForeground() before returning true. The application must also handle notification permission, foreground Service start timing, and background-start restrictions for the target Android version.
If no hook is registered, transfers are interrupted when the system terminates the application process. Task records are restored the next time the application starts. Tasks that were in-progress, when interrupted, are normalized to a paused state, and the UI should prompt the user to call RESUME.