A factory class to set up aMenuItem
or a
MediaRouteButton
to be used as a Cast button. The SDK will set aMediaRouteSelector
which is built by theCastContext
,
based on the discovery options set insideCastOptions
.
Public Method Summary
static void | |
staticMenuItem |
setUpMediaRouteButton(Context
context,Menumenu, int
menuResourceId)
Sets up the
MediaRouteActionProvider
inmenu .
|
static Task<Void> |
setUpMediaRouteButton(Context
context,Executor
executor, MediaRouteButton button)
Sets up the given
MediaRouteButton
with an asynchronous call, which will not block the caller thread.
|
static Task<MenuItem> |
setUpMediaRouteButton(Context
context,Executor
executor,Menumenu, int
menuResourceId)
Sets up the
MediaRouteActionProvider
inmenu with an asynchronous call, which will not block the caller
thread.
|
Inherited Method Summary
Public Methods
public static voidsetUpMediaRouteButton(Contextcontext, MediaRouteButton button)
Sets up the givenMediaRouteButton
.
Parameters
context | The applicationContext . |
---|---|
button | TheMediaRouteButton
instance to set up. |
Throws
IllegalStateException | If this method is not called on the main thread. |
---|
public staticMenuItem setUpMediaRouteButton(Contextcontext, Menumenu, int menuResourceId)
Sets up theMediaRouteActionProvider
inmenu
.Returns theMenuItem
of
theMediaRouteActionProvider
.
Parameters
context | The applicationContext . |
---|---|
menu | Menu reference. |
menuResourceId | The resource id of the cast button in the xml menu descriptor file. |
Throws
IllegalArgumentException | Ifmenu doesn't contain a menu item with
menuResourceId identifier, or the menu item doesn't have a
MediaRouteActionProvider . |
---|---|
IllegalStateException | If this method is not called on the main thread. |
public static Task<Void>setUpMediaRouteButton(Contextcontext, Executor executor, MediaRouteButton button)
Sets up the givenMediaRouteButton
with an asynchronous call, which will not block the caller thread.
Note that
ModuleUnavailableException
could be thrown when the SDK fails to load the
internal Cast module. The caller will get the exception fromTask.getException()
when the task completes.
Parameters
context | The applicationContext . |
---|---|
executor | AnExecutor
to load the internal Cast module if needed. |
button | TheMediaRouteButton
instance to set up. |
Throws
IllegalStateException | If this method is not called on the main thread. |
---|
public static Task<MenuItem> setUpMediaRouteButton(Contextcontext, Executor executor,Menumenu, int menuResourceId)
Sets up theMediaRouteActionProvider
inmenu
with an asynchronous call, which will not block the caller thread.
Returns theMenuItem
of
theMediaRouteActionProvider
.
Note that
ModuleUnavailableException
could be thrown when the SDK fails to load the
internal Cast module. The caller will get the exception fromTask.getException()
when the task completes.
Parameters
context | The applicationContext . |
---|---|
executor | AnExecutor
to load the internal Cast module if needed. |
menu | Menu reference. |
menuResourceId | The resource id of the cast button in the xml menu descriptor file. |
Throws
IllegalArgumentException | Ifmenu doesn't contain a menu item with
menuResourceId identifier, or the menu item doesn't have a
MediaRouteActionProvider . |
---|---|
IllegalStateException | If this method is not called on the main thread. |