Most visited

Recently visited

MediaRouteProviderService

public abstract class MediaRouteProviderService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.support.v7.media.MediaRouteProviderService


媒体路由提供商服务的基类。

媒体路由器将与媒体航线提供服务时的回调是通过添加 addCallback(MediaRouteSelector, MediaRouter.Callback, int)与发现标志: CALLBACK_FLAG_REQUEST_DISCOVERYCALLBACK_FLAG_FORCE_DISCOVERY ,或 CALLBACK_FLAG_PERFORM_ACTIVE_SCAN ,当回调是通过去除将解除绑定 removeCallback(MediaRouter.Callback)

要实现您自己的媒体路由提供商服务,请扩展此类并覆盖 onCreateMediaRouteProvider()方法以返回您的 MediaRouteProvider的实例。

在您的应用程序清单中声明您的媒体路由提供者服务,如下所示

   <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

String SERVICE_INTERFACE

必须声明为由服务处理的 Intent

Inherited constants

From class android.app.Service
From class android.content.Context
From interface android.content.ComponentCallbacks2

Public constructors

MediaRouteProviderService()

创建媒体路由提供者服务。

Public methods

MediaRouteProvider getMediaRouteProvider()

获取此服务提供的媒体路由提供程序。

IBinder onBind(Intent intent)

将通信信道返回给服务。

abstract MediaRouteProvider onCreateMediaRouteProvider()

当系统创建媒体路由提供者时,由系统调用。

boolean onUnbind(Intent intent)

当所有客户端与服务发布的特定接口断开连接时调用。

Inherited methods

From class android.app.Service
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks2
From interface android.content.ComponentCallbacks

Constants

SERVICE_INTERFACE

String SERVICE_INTERFACE

Intent必须声明为由服务处理。 把它放在你的清单中。

常量值:“android.media.MediaRouteProviderService”

Public constructors

MediaRouteProviderService

MediaRouteProviderService ()

创建媒体路由提供者服务。

Public methods

getMediaRouteProvider

MediaRouteProvider getMediaRouteProvider ()

获取此服务提供的媒体路由提供程序。

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

也可以看看:

onBind

IBinder onBind (Intent intent)

将通信信道返回给服务。 如果客户端无法绑定到服务,可能会返回null。 返回IBinder通常是一个复杂的界面已经described using aidl

请注意,与其他应用程序组件不同,此处返回的IBinder接口调用可能不会发生在进程的主线程上 有关主线程的更多信息可以在Processes and Threads中找到。

Parameters
intent Intent: The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.
Returns
IBinder Return an IBinder through which clients can call on to the service.

onCreateMediaRouteProvider

MediaRouteProvider onCreateMediaRouteProvider ()

当系统创建媒体路由提供者时,由系统调用。

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

onUnbind

boolean onUnbind (Intent intent)

当所有客户端与服务发布的特定接口断开连接时调用。 默认实现什么也不做,并返回false。

Parameters
intent Intent: The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.
Returns
boolean Return true if you would like to have the service's onRebind(Intent) method later called when new clients bind to it.

Hooray!