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
This commit is contained in:
parent
d777a11840
commit
41722be02e
@ -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,
|
* Sets the timeout for a session to stay in a foreground service state after it paused, stopped,
|
||||||
* failed or ended.
|
* 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>Has no effect on already running timeouts.
|
||||||
*
|
*
|
||||||
* <p>The default and maximum value is {@link #DEFAULT_FOREGROUND_SERVICE_TIMEOUT_MS}. If a larger
|
* <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) {
|
synchronized (lock) {
|
||||||
if (mediaNotificationManager == null) {
|
if (mediaNotificationManager == null) {
|
||||||
if (mediaNotificationProvider == null) {
|
if (mediaNotificationProvider == null) {
|
||||||
|
checkStateNotNull(getBaseContext(), "Accessing service context before onCreate()");
|
||||||
mediaNotificationProvider =
|
mediaNotificationProvider =
|
||||||
new DefaultMediaNotificationProvider.Builder(getApplicationContext()).build();
|
new DefaultMediaNotificationProvider.Builder(getApplicationContext()).build();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user