mediarouter/src/main/java/androidx/mediarouter/app/MediaRouteButton.java
public boolean showDialog() {
        if (!mAttachedToWindow) {
            return false;
        }

        final FragmentManager fm = getFragmentManager();
        if (fm == null) {
            throw new IllegalStateException("The activity must be a subclass of FragmentActivity");
        }

        MediaRouter.RouteInfo route = mRouter.getSelectedRoute();
        if (route.isDefaultOrBluetooth() || !route.matchesSelector(mSelector)) {
            if (fm.findFragmentByTag(CHOOSER_FRAGMENT_TAG) != null) {
                Log.w(TAG, "showDialog(): Route chooser dialog already showing!");
                return false;
            }
            MediaRouteChooserDialogFragment f =
                    mDialogFactory.onCreateChooserDialogFragment();
            f.setRouteSelector(mSelector);
            f.show(fm, CHOOSER_FRAGMENT_TAG);
        } else {
            if (fm.findFragmentByTag(CONTROLLER_FRAGMENT_TAG) != null) {
                Log.w(TAG, "showDialog(): Route controller dialog already showing!");
                return false;
            }
            MediaRouteControllerDialogFragment f =
                    mDialogFactory.onCreateControllerDialogFragment();
            f.show(fm, CONTROLLER_FRAGMENT_TAG);
        }
        return true;
    }
/**
     * Show the route chooser or controller dialog.
     * <p>
     * If the default route is selected or if the currently selected route does
     * not match the {@link #getRouteSelector selector}, 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.
     * </p><p>
     * The application can customize the dialogs by calling {@link #setDialogFactory}
     * to provide a customized dialog factory.
     * </p>
     *
     * @return True if the dialog was actually shown.
     *
     * @throws IllegalStateException if the activity is not a subclass of
     * {@link FragmentActivity}.
     */
Show the route chooser or controller dialog.

If the default route is selected or if the currently selected route does
not match the  #getRouteSelector selector, 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.

The application can customize the dialogs by calling  #setDialogFactory
to provide a customized dialog factory.

@return True if the dialog was actually shown.

@throws IllegalStateException if the activity is not a subclass of
FragmentActivity.
Show the route chooser or controller dialog . If the default route is selected or if the currently selected route does not match the #getRouteSelector selector 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 . The application can customize the dialogs by calling #setDialogFactory to provide a customized dialog factory . @return True if the dialog was actually shown . @throws IllegalStateException if the activity is not a subclass of FragmentActivity .
public boolean showDialog() {
        if (!mAttachedToWindow) {
            return false;
        }
        final FragmentManager fm = getFragmentManager();
        if (fm == null) {
            throw new IllegalStateException("The activity must be a subclass of FragmentActivity");
        }
        MediaRouter.RouteInfo route = mRouter.getSelectedRoute();
        if (route.isDefaultOrBluetooth() || !route.matchesSelector(mSelector)) {
            if (fm.findFragmentByTag(CHOOSER_FRAGMENT_TAG) != null) {
                Log.w(TAG, "showDialog(): Route chooser dialog already showing!");
                return false;
            }
            MediaRouteChooserDialogFragment f =
                    mDialogFactory.onCreateChooserDialogFragment();
            f.setRouteSelector(mSelector);
            f.show(fm, CHOOSER_FRAGMENT_TAG);
        } else {
            if (fm.findFragmentByTag(CONTROLLER_FRAGMENT_TAG) != null) {
                Log.w(TAG, "showDialog(): Route controller dialog already showing!");
                return false;
            }
            MediaRouteControllerDialogFragment f =
                    mDialogFactory.onCreateControllerDialogFragment();
            f.show(fm, CONTROLLER_FRAGMENT_TAG);
        }
        return true;
    }
public boolean showDialog ( ) { if ( ! mAttachedToWindow ) { return false ; } final FragmentManager fm = getFragmentManager ( ) ; if ( fm == null ) { throw new IllegalStateException ( "The activity must be a subclass of FragmentActivity" ) ; } MediaRouter . RouteInfo route = mRouter . getSelectedRoute ( ) ; if ( route . isDefaultOrBluetooth ( ) || ! route . matchesSelector ( mSelector ) ) { if ( fm . findFragmentByTag ( CHOOSER_FRAGMENT_TAG ) != null ) { Log . w ( TAG , "showDialog(): Route chooser dialog already showing!" ) ; return false ; } MediaRouteChooserDialogFragment f = mDialogFactory . onCreateChooserDialogFragment ( ) ; f . setRouteSelector ( mSelector ) ; f . show ( fm , CHOOSER_FRAGMENT_TAG ) ; } else { if ( fm . findFragmentByTag ( CONTROLLER_FRAGMENT_TAG ) != null ) { Log . w ( TAG , "showDialog(): Route controller dialog already showing!" ) ; return false ; } MediaRouteControllerDialogFragment f = mDialogFactory . onCreateControllerDialogFragment ( ) ; f . show ( fm , CONTROLLER_FRAGMENT_TAG ) ; } return true ; }
Show the route chooser or controller dialog.
Show the route chooser or controller dialog .