@@ -166,6 +166,39 @@ default void onForegroundServiceStartNotAllowedException() {}
166166 /** The action for {@link Intent} filter that must be declared by the service. */
167167 public static final String SERVICE_INTERFACE = "androidx.media3.session.MediaSessionService" ;
168168
169+ /**
170+ * The action of an {@link Intent} sent to this service by itself when it is already running, but
171+ * wishes to move into the foreground state.
172+ *
173+ * <p>This action is not intended for starting the service from anywhere except custom foreground
174+ * service handling. Most apps will never need to send this action themselves.
175+ *
176+ * <p>If an {@link Intent} with this action is received in a subclass' {@link
177+ * #onStartCommand(Intent, int, int)} method, the intent should be passed to the superclass
178+ * (MediaSessionService) implementation. No further action is required to handle it.
179+ */
180+ @ UnstableApi
181+ public static final String ACTION_START_SELF =
182+ "androidx.media3.session.MediaSessionService.ACTION_START_SELF" ;
183+
184+ /**
185+ * The action of an {@link Intent} sent to this service by the system when a custom notification
186+ * or session action was clicked.
187+ *
188+ * <p>If an {@link Intent} with this action is received in a subclass' {@link
189+ * #onStartCommand(Intent, int, int)} method, the intent should be passed to the superclass
190+ * (MediaSessionService) implementation.
191+ *
192+ * <p>This {@link Intent} is not intended to be intercepted by subclasses. If subclasses wish to
193+ * handle custom notification actions, {@link
194+ * MediaNotification.Provider#handleCustomCommand(MediaSession, String, Bundle)} or {@link
195+ * MediaSession.Callback#onCustomCommand(MediaSession, ControllerInfo, SessionCommand, Bundle)}
196+ * are appropriate.
197+ */
198+ @ UnstableApi
199+ public static final String ACTION_CUSTOM_NOTIFICATION_ACTION =
200+ "androidx.media3.session.CUSTOM_NOTIFICATION_ACTION" ;
201+
169202 /**
170203 * The default timeout for a session to stay in a foreground service state after it paused,
171204 * stopped, failed or ended.
@@ -439,9 +472,18 @@ public IBinder onBind(@Nullable Intent intent) {
439472 /**
440473 * Called when a component calls {@link android.content.Context#startService(Intent)}.
441474 *
442- * <p>The default implementation handles the incoming media button events. In this case, the
443- * intent will have the action {@link Intent#ACTION_MEDIA_BUTTON}. Override this method if this
444- * service also needs to handle actions other than {@link Intent#ACTION_MEDIA_BUTTON}.
475+ * <p>The default implementation handles the following events:
476+ *
477+ * <ul>
478+ * <li>incoming media button events with the {@link Intent} action {@link
479+ * Intent#ACTION_MEDIA_BUTTON}.
480+ * <li>custom notification actions with {@link Intent} action {@link
481+ * #ACTION_CUSTOM_NOTIFICATION_ACTION}
482+ * <li>foreground service state changes with {@link Intent} action {@link #ACTION_START_SELF}
483+ * </ul>
484+ *
485+ * <p>Override this method if this service also needs to handle actions other than those mentioned
486+ * above.
445487 *
446488 * <p>This method will be called on the main thread.
447489 */
0 commit comments