MediaRouteProviderService
public abstract class MediaRouteProviderService extends Service
| java.lang.Object | ||||
| ↳ | android.content.Context | |||
| ↳ | android.content.ContextWrapper | |||
| ↳ | android.app.Service | |||
| ↳ | androidx.mediarouter.media.MediaRouteProviderService |
Base class for media route provider services.
A media router will bind to media route provider services when a callback is added via addCallback with a discovery flag: CALLBACK_FLAG_REQUEST_DISCOVERY, CALLBACK_FLAG_FORCE_DISCOVERY, or CALLBACK_FLAG_PERFORM_ACTIVE_SCAN, and will unbind when the callback is removed via removeCallback.
To implement your own media route provider service, extend this class and override the onCreateMediaRouteProvider method to return an instance of your MediaRouteProvider.
Declare your media route provider service in your application manifest like this:
<service android:name=".MyMediaRouteProviderService" android:label="@string/my_media_route_provider_service"> <intent-filter> <action android:name="android.media.MediaRouteProviderService" /> </intent-filter> </service>
Summary
Nested types |
|---|
public final class MediaRouteProviderService.ClientInfoContains information about a client that is bound to this service. |
public final class MediaRouteProviderService.ClientInfo.BuilderBuilder for |
Constants |
|
|---|---|
static final String |
SERVICE_INTERFACE = "android.media.MediaRouteProviderService"The |
Public constructors |
|---|
|
Creates a media route provider service. |
Public methods |
|
|---|---|
void |
addClientInfoListener(Adds a |
@Nullable MediaRouteProvider |
Gets the media route provider offered by this service. |
@Nullable IBinder |
|
abstract @Nullable MediaRouteProvider |
Called by the system when it is time to create the media route provider. |
void |
|
void |
Removes the given |
Protected methods |
|
|---|---|
void |
attachBaseContext(@NonNull Context context) |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Inherited methods |
||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||
|
Constants
SERVICE_INTERFACE
public static final String SERVICE_INTERFACE = "android.media.MediaRouteProviderService"
The Intent that must be declared as handled by the service. Put this in your manifest.
Public constructors
MediaRouteProviderService
public MediaRouteProviderService()
Creates a media route provider service.
Public methods
addClientInfoListener
public void addClientInfoListener(
@NonNull Executor listenerExecutor,
@NonNull Consumer<List<MediaRouteProviderService.ClientInfo>> listener
)
Adds a Consumer that will be used to provide updates when the list of bound clients changes.
The Consumer will be called with the current list of bound clients.
| Parameters | |
|---|---|
@NonNull Executor listenerExecutor |
an |
@NonNull Consumer<List<MediaRouteProviderService.ClientInfo>> listener |
a @code |
getMediaRouteProvider
public @Nullable MediaRouteProvider getMediaRouteProvider()
Gets the media route provider offered by this service.
| Returns | |
|---|---|
@Nullable MediaRouteProvider |
The media route provider offered by this service, or null if it has not yet been created. |
| See also | |
|---|---|
onCreateMediaRouteProvider |
onCreateMediaRouteProvider
public abstract @Nullable MediaRouteProvider onCreateMediaRouteProvider()
Called by the system when it is time to create the media route provider.
| Returns | |
|---|---|
@Nullable MediaRouteProvider |
The media route provider offered by this service, or null if this service has decided not to offer a media route provider. |
removeClientInfoListener
public void removeClientInfoListener(
@NonNull Consumer<List<MediaRouteProviderService.ClientInfo>> listener
)
Removes the given Consumer if it was previously set.
| Parameters | |
|---|---|
@NonNull Consumer<List<MediaRouteProviderService.ClientInfo>> listener |
the |
| See also | |
|---|---|
addClientInfoListener |