MediaRouteProviderService
abstract class MediaRouteProviderService : Service
kotlin.Any | ||||
↳ | 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 |
---|
Contains information about a client that is bound to this service. |
Builder for |
Constants |
|
---|---|
const String! |
SERVICE_INTERFACE = "android.media.MediaRouteProviderService" The |
Public constructors |
---|
Creates a media route provider service. |
Public functions |
|
---|---|
Unit |
addClientInfoListener( Adds a |
MediaRouteProvider? |
Gets the media route provider offered by this service. |
IBinder? |
|
abstract MediaRouteProvider? |
Called by the system when it is time to create the media route provider. |
Unit |
|
Unit |
removeClientInfoListener( Removes the given |
Protected functions |
|
---|---|
Unit |
attachBaseContext(context: Context) |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Constants
SERVICE_INTERFACE
const val SERVICE_INTERFACE = "android.media.MediaRouteProviderService": String!
The Intent
that must be declared as handled by the service. Put this in your manifest.
Public constructors
MediaRouteProviderService
MediaRouteProviderService()
Creates a media route provider service.
Public functions
addClientInfoListener
fun addClientInfoListener(
listenerExecutor: Executor,
listener: Consumer<(Mutable)List<MediaRouteProviderService.ClientInfo!>!>
): Unit
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 | |
---|---|
listenerExecutor: Executor |
an |
listener: Consumer<(Mutable)List<MediaRouteProviderService.ClientInfo!>!> |
a @code |
getMediaRouteProvider
fun getMediaRouteProvider(): MediaRouteProvider?
Gets the media route provider offered by this service.
Returns | |
---|---|
MediaRouteProvider? |
The media route provider offered by this service, or null if it has not yet been created. |
See also | |
---|---|
onCreateMediaRouteProvider |
onCreateMediaRouteProvider
abstract fun onCreateMediaRouteProvider(): MediaRouteProvider?
Called by the system when it is time to create the media route provider.
Returns | |
---|---|
MediaRouteProvider? |
The media route provider offered by this service, or null if this service has decided not to offer a media route provider. |
removeClientInfoListener
fun removeClientInfoListener(
listener: Consumer<(Mutable)List<MediaRouteProviderService.ClientInfo!>!>
): Unit
Removes the given Consumer
if it was previously set.
Parameters | |
---|---|
listener: Consumer<(Mutable)List<MediaRouteProviderService.ClientInfo!>!> |
the |
See also | |
---|---|
addClientInfoListener |