com.google.android.gms.cast.framework.IntroductoryOverlay |
A simple overlay view that highlights the Cast button to the user. To show this overlay, use
IntroductoryOverlay.Builder
to build an instance of this interface and call show()
:
IntroductoryOverlay overlay = new IntroductoryOverlay.Builder(activity, mMediaRouteMenuItem) .setTitleText(R.string.cast_intro_overlay_text) .setOnDismissed(onOverlayDismissedListener) .setSingleTime() .build(); overlay.show();Here,
mMediaRouteMenuItem
is the MenuItem
reference to the cast button (returned
when you call setUpMediaRouteButton(Context, MediaRouteButton)
). You can alternatively provide an
instance of a MediaRouteButton
.
This overlay highlights the Cast button to the user, and shows a text introduction. On
older APIs prior to JELLY_BEAN it also shows a button to dismiss the overlay.
IntroductoryOverlay.Builder
lets you customize the overlay.
On older APIs prior to JELLY_BEAN, you can also change the margin of the title and button by
overriding R.dimen.cast_intro_overlay_title_margin_top
and
R.dimen.cast_intro_overlay_button_margin_bottom
.
In order to show this overlay at the right time, clients can register to
CastStateListener
to find out when the Cast button becomes visible.
mCastStateListener = new CastStateListener() { @Override public void onCastStateChanged(int newState) { if (newState != CastState.NO_DEVICES_AVAILABLE) { showIntroductoryOverlay(); } } };And check to make sure the menu item is visible:
if ((mediaRouteMenuItem != null) && mediaRouteMenuItem.isVisible()) { new Handler().post(new Runnable() { @Override public void run() { mIntroductoryOverlay = new IntroductoryOverlay.Builder( MyActivity.this, mediaRouteMenuItem) .setTitleText("Introducing Cast") .setSingleTime() .setOnOverlayDismissedListener( new IntroductoryOverlay.OnOverlayDismissedListener() { @Override public void onOverlayDismissed() { ...... } }) .build(); mIntroductoryOverlay.show(); } }); }Management of how often this overlay should be shown is left to the client application.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
IntroductoryOverlay.Builder | The builder class that creates an instance of IntroductoryOverlay . |
||||||||||
IntroductoryOverlay.OnOverlayDismissedListener | An interface to notify the clients when the overlay is dismissed explicitly when the user taps on the confirmation button. |
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
com.google.android.gms:castBackgroundColor | |||||||||||
com.google.android.gms:castButtonBackgroundColor | |||||||||||
com.google.android.gms:castButtonText | |||||||||||
com.google.android.gms:castButtonTextAppearance | |||||||||||
com.google.android.gms:castFocusRadius | |||||||||||
com.google.android.gms:castTitleTextAppearance |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Removes the overlay and frees the resources used.
| |||||||||||
Shows the overlay if it is not visible already.
|
Removes the overlay and frees the resources used. It also removes the reference to the activity that was used to build this overlay to avoid any leaks. When user taps on the button in this overlay, this method will be called automatically. After calling this method, for all practical purposes, this component cannot be re-used.
Shows the overlay if it is not visible already.