Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
405455b0
authored
Oct 20, 2022
by
Marc Baechinger
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge pull request #183 from jasper-apps:bugfix/make-download-notification-appear-immediately
PiperOrigin-RevId: 482165983
parents
7d5f1a24
ed55d0b5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
library/core/src/main/java/com/google/android/exoplayer2/ui/DownloadNotificationHelper.java
library/core/src/main/java/com/google/android/exoplayer2/ui/DownloadNotificationHelper.java
View file @
405455b0
...
...
@@ -15,17 +15,23 @@
*/
package
com
.
google
.
android
.
exoplayer2
.
ui
;
import
static
androidx
.
core
.
app
.
NotificationCompat
.
FOREGROUND_SERVICE_IMMEDIATE
;
import
android.annotation.SuppressLint
;
import
android.app.Notification
;
import
android.app.PendingIntent
;
import
android.content.Context
;
import
androidx.annotation.DoNotInline
;
import
androidx.annotation.DrawableRes
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.RequiresApi
;
import
androidx.annotation.StringRes
;
import
androidx.core.app.NotificationCompat
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.core.R
;
import
com.google.android.exoplayer2.offline.Download
;
import
com.google.android.exoplayer2.scheduler.Requirements
;
import
com.google.android.exoplayer2.util.Util
;
import
java.util.List
;
/** Helper for creating download notifications. */
...
...
@@ -236,6 +242,19 @@ public final class DownloadNotificationHelper {
notificationBuilder
.
setProgress
(
maxProgress
,
currentProgress
,
indeterminateProgress
);
notificationBuilder
.
setOngoing
(
ongoing
);
notificationBuilder
.
setShowWhen
(
showWhen
);
if
(
Util
.
SDK_INT
>=
31
)
{
Api31
.
setForegroundServiceBehavior
(
notificationBuilder
);
}
return
notificationBuilder
.
build
();
}
@RequiresApi
(
31
)
private
static
final
class
Api31
{
@SuppressLint
(
"WrongConstant"
)
// TODO(b/254277605): remove lint suppression
@DoNotInline
public
static
void
setForegroundServiceBehavior
(
NotificationCompat
.
Builder
notificationBuilder
)
{
notificationBuilder
.
setForegroundServiceBehavior
(
FOREGROUND_SERVICE_IMMEDIATE
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment