MediaRouteButton


public class MediaRouteButton
extends View

java.lang.Object
   ↳ android.view.View
     ↳ android.app.MediaRouteButton


Summary

Inherited XML attributes

Inherited constants

Inherited fields

Public constructors

MediaRouteButton(Context context)
MediaRouteButton(Context context, AttributeSet attrs)
MediaRouteButton(Context context, AttributeSet attrs, int defStyleAttr)
MediaRouteButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public methods

int getRouteTypes()

Gets the media route types for filtering the routes that the user can select using the media route chooser dialog.

void jumpDrawablesToCurrentState()

Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.

void onAttachedToWindow()

This is called when the view is attached to a window.

void onDetachedFromWindow()

This is called when the view is detached from a window.

boolean performClick()

Call this view's OnClickListener, if it is defined.

void setContentDescription(CharSequence contentDescription)

Sets the View's content description.

void setExtendedSettingsClickListener(View.OnClickListener listener)
void setRouteTypes(int types)

Sets the types of routes that will be shown in the media route chooser dialog launched by this button.

void setVisibility(int visibility)

Set the visibility state of this view.

void showDialog()

Show the route chooser or controller dialog.

Protected methods

void drawableStateChanged()

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

int[] onCreateDrawableState(int extraSpace)

Generate the new Drawable state for this view.

void onDraw(Canvas canvas)

Implement this to do your drawing.

void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

boolean verifyDrawable(Drawable who)

If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying.

Inherited methods

Public constructors

MediaRouteButton

Added in API level 16
public MediaRouteButton (Context context)

Parameters
context Context

MediaRouteButton

Added in API level 16
public MediaRouteButton (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

MediaRouteButton

Added in API level 16
public MediaRouteButton (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

MediaRouteButton

Added in API level 21
public MediaRouteButton (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

defStyleRes int

Public methods

getRouteTypes

Added in API level 16
public int getRouteTypes ()

Gets the media route types for filtering the routes that the user can select using the media route chooser dialog.

Returns
int The route types.

jumpDrawablesToCurrentState

Added in API level 16
public void jumpDrawablesToCurrentState ()

Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.

Also calls StateListAnimator#jumpToCurrentState() if there is a StateListAnimator attached to this view.
If you override this method you must call through to the superclass implementation.

onAttachedToWindow

Added in API level 16
public void onAttachedToWindow ()

This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(android.graphics.Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).
If you override this method you must call through to the superclass implementation.

onDetachedFromWindow

Added in API level 16
public void onDetachedFromWindow ()

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.
If you override this method you must call through to the superclass implementation.

performClick

Added in API level 16
public boolean performClick ()

Call this view's OnClickListener, if it is defined. Performs all normal actions associated with clicking: reporting accessibility event, playing a sound, etc.

Returns
boolean True there was an assigned OnClickListener that was called, false otherwise is returned.

setContentDescription

Added in API level 16
public void setContentDescription (CharSequence contentDescription)

Sets the View's content description.

A content description briefly describes the view and is primarily used for accessibility support to determine how a view should be presented to the user. In the case of a view with no textual representation, such as ImageButton, a useful content description explains what the view does. For example, an image button with a phone icon that is used to place a call may use "Call" as its content description. An image of a floppy disk that is used to save a file may use "Save".

This should omit role or state. Role refers to the kind of user-interface element the View is, such as a Button or Checkbox. State refers to a frequently changing property of the View, such as an On/Off state of a button or the audio level of a volume slider.

Content description updates are not frequent, and are used when the semantic content - not the state - of the element changes. For example, a Play button might change to a Pause button during music playback.

Parameters
contentDescription CharSequence: The content description.

setExtendedSettingsClickListener

Added in API level 16
public void setExtendedSettingsClickListener (View.OnClickListener listener)

Parameters
listener View.OnClickListener

setRouteTypes

Added in API level 16
public void setRouteTypes (int types)

Sets the types of routes that will be shown in the media route chooser dialog launched by this button.

Parameters
types int: The route types to match.

setVisibility

Added in API level 16
public void setVisibility (int visibility)

Set the visibility state of this view.

Parameters
visibility int: One of View.VISIBLE, View.INVISIBLE, or View.GONE. Value is View.VISIBLE, View.INVISIBLE, or View.GONE

showDialog

Added in API level 16
public void showDialog ()

Show the route chooser or controller dialog.

If the default route is selected or if the currently selected route does not match the route types, then shows the route chooser dialog. Otherwise, shows the route controller dialog to offer the user a choice to disconnect from the route or perform other control actions such as setting the route's volume.

This will attach a DialogFragment to the containing Activity.

Protected methods

drawableStateChanged

Added in API level 16
protected void drawableStateChanged ()

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

If the View has a StateListAnimator, it will also be called to run necessary state change animations.

Be sure to call through to the superclass when overriding this function.
If you override this method you must call through to the superclass implementation.

onCreateDrawableState

Added in API level 16
protected int[] onCreateDrawableState (int extraSpace)

Generate the new Drawable state for this view. This is called by the view system when the cached Drawable state is determined to be invalid. To retrieve the current state, you should use getDrawableState().

Parameters
extraSpace int: if non-zero, this is the number of extra entries you would like in the returned array in which you can place your own states.

Returns
int[] Returns an array holding the current Drawable state of the view.

onDraw

Added in API level 16
protected void onDraw (Canvas canvas)

Implement this to do your drawing.

Parameters
canvas Canvas: the canvas on which the background will be drawn This value cannot be null.

onMeasure

Added in API level 16
protected void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overridden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int, int). Calling the superclass' onMeasure(int, int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int, int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).

Parameters
widthMeasureSpec int: horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.

heightMeasureSpec int: vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.

verifyDrawable

Added in API level 16
protected boolean verifyDrawable (Drawable who)

If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying. This allows animations for those drawables to be scheduled.

Be sure to call through to the super class when overriding this function.
If you override this method you must call through to the superclass implementation.

Parameters
who Drawable: This value cannot be null.

Returns
boolean boolean If true then the Drawable is being displayed in the view; else false and it is not allowed to animate.