mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Clarify that method can only be called after onCreate
And improve error message if access to the notification controller happens without a base context. #cherrypick PiperOrigin-RevId: 736545574 (cherry picked from commit 41722be02e34199543dc92c44e12ff95a35cb378)
This commit is contained in:
parent
97606094ca
commit
23468ed55c
@ -481,6 +481,9 @@ public abstract class MediaSessionService extends Service {
|
||||
* Sets the timeout for a session to stay in a foreground service state after it paused, stopped,
|
||||
* failed or ended.
|
||||
*
|
||||
* <p>Can only be called once the {@link Context} of the service is initialized in {@link
|
||||
* #onCreate()}.
|
||||
*
|
||||
* <p>Has no effect on already running timeouts.
|
||||
*
|
||||
* <p>The default and maximum value is {@link #DEFAULT_FOREGROUND_SERVICE_TIMEOUT_MS}. If a larger
|
||||
@ -679,6 +682,7 @@ public abstract class MediaSessionService extends Service {
|
||||
synchronized (lock) {
|
||||
if (mediaNotificationManager == null) {
|
||||
if (mediaNotificationProvider == null) {
|
||||
checkStateNotNull(getBaseContext(), "Accessing service context before onCreate()");
|
||||
mediaNotificationProvider =
|
||||
new DefaultMediaNotificationProvider.Builder(getApplicationContext()).build();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user