Google is committed to advancing racial equity for Black communities. See how.

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 MediaRouter#addCallback(MediaRouteSelector, MediaRouter.Callback, int) with a discovery flag: MediaRouter#CALLBACK_FLAG_REQUEST_DISCOVERY, MediaRouter#CALLBACK_FLAG_FORCE_DISCOVERY, or MediaRouter#CALLBACK_FLAG_PERFORM_ACTIVE_SCAN, and will unbind when the callback is removed via MediaRouter#removeCallback(MediaRouter.Callback).

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

Constants
static String

The Intent that must be declared as handled by the service.

Public constructors

Creates a media route provider service.

Public methods
open MediaRouteProvider!

Gets the media route provider offered by this service.

open IBinder?
onBind(intent: Intent!)

abstract MediaRouteProvider!

Called by the system when it is time to create the media route provider.

open Unit

Protected methods
open Unit
attachBaseContext(@NonNull context: Context)

Constants

SERVICE_INTERFACE

static val SERVICE_INTERFACE: String

The Intent that must be declared as handled by the service. Put this in your manifest.

Value: MediaRouteProviderProtocol.SERVICE_INTERFACE

Public constructors

<init>

MediaRouteProviderService()

Creates a media route provider service.

Public methods

getMediaRouteProvider

open fun getMediaRouteProvider(): MediaRouteProvider!

Gets the media route provider offered by this service.

Return
MediaRouteProvider! The media route provider offered by this service, or null if it has not yet been created.

onBind

open fun onBind(intent: Intent!): IBinder?

onCreateMediaRouteProvider

abstract fun onCreateMediaRouteProvider(): MediaRouteProvider!

Called by the system when it is time to create the media route provider.

Return
MediaRouteProvider! The media route provider offered by this service, or null if this service has decided not to offer a media route provider.

onDestroy

open fun onDestroy(): Unit

Protected methods

attachBaseContext

protected open fun attachBaseContext(@NonNull context: Context): Unit