Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make download notification appear immediately #183

Conversation

yterletskyi
Copy link

Since Android 12 (API 31) notifications produced by startForeground method wait 10 seconds until showing. This could be confusing to user who use DownloadNotificationHelper methods to build notifications to show in a custom DownloadService (protected abstract Notification getForegroundNotification(List<Download> downloads, @RequirementFlags int notMetRequirements);).

Docs excerpt:

Devices that run Android 12 (API level 31) or higher provide a streamlined experience for short-running foreground services. On these devices, the system waits 10 seconds before showing the notification associated with a foreground service. There are a few exceptions; several types of services always display a notification immediately.

To make the notifications be shown immediately once actual download operation is started, FOREGROUND_SERVICE_IMMEDIATE can be set to NotificationCompat.Builder.setForegroundServiceBehavior().
See: https://developer.android.com/guide/components/foreground-services#notification-immediate

@rohitjoins rohitjoins merged commit 1565a2d into androidx:main Oct 24, 2022
microkatz pushed a commit that referenced this pull request Nov 22, 2022
…ation-appear-immediately

PiperOrigin-RevId: 482165983
(cherry picked from commit 1565a2d)
icbaker pushed a commit that referenced this pull request Nov 24, 2022
…ation-appear-immediately

PiperOrigin-RevId: 482165983
icbaker pushed a commit that referenced this pull request Dec 12, 2022
…ation-appear-immediately

PiperOrigin-RevId: 482165983
(cherry picked from commit 405455b)
@androidx androidx locked and limited conversation to collaborators Mar 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants