IntroductoryOverlay

public interface 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 Class Summary

class IntroductoryOverlay.Builder The builder class that creates an instance of IntroductoryOverlay
interface IntroductoryOverlay.OnOverlayDismissedListener An interface to notify the clients when the overlay is dismissed explicitly when the user taps on the confirmation button. 

XML Attribute Summary

Public Method Summary

abstract void
remove()
Removes the overlay and frees the resources used.
abstract void
show()
Shows the overlay if it is not visible already.

XML Attributes

CastIntroOverlay_castBackgroundColor

Related Methods

    CastIntroOverlay_castButtonBackgroundColor

    Related Methods

      CastIntroOverlay_castButtonText

      Related Methods

        CastIntroOverlay_castButtonTextAppearance

        Related Methods

          CastIntroOverlay_castFocusRadius

          Related Methods

            CastIntroOverlay_castTitleTextAppearance

            Related Methods

              Public Methods

              public abstract void remove ()

              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.

              public abstract void show ()

              Shows the overlay if it is not visible already.

              Attribute Name
              CastIntroOverlay_castBackgroundColor
              CastIntroOverlay_castButtonBackgroundColor
              CastIntroOverlay_castButtonText
              CastIntroOverlay_castButtonTextAppearance
              CastIntroOverlay_castFocusRadius
              CastIntroOverlay_castTitleTextAppearance