/** * Asynchronously show the route chooser dialog. This will attach a {@link DialogFragment} to the * containing Activity. */ public void showDialog() { final FragmentManager fm = getActivity().getFragmentManager(); if (mDialogFragment == null) { // See if one is already attached to this activity. mDialogFragment = (MediaRouteChooserDialogFragment) fm.findFragmentByTag(MediaRouteChooserDialogFragment.FRAGMENT_TAG); } if (mDialogFragment != null) { Log.w(TAG, "showDialog(): Already showing!"); return; } mDialogFragment = new MediaRouteChooserDialogFragment(); mDialogFragment.setExtendedSettingsClickListener(mExtendedSettingsClickListener); mDialogFragment.setLauncherListener( new MediaRouteChooserDialogFragment.LauncherListener() { @Override public void onDetached(MediaRouteChooserDialogFragment detachedFragment) { mDialogFragment = null; } }); mDialogFragment.setRouteTypes(mRouteTypes); mDialogFragment.show(fm, MediaRouteChooserDialogFragment.FRAGMENT_TAG); }
@Override public void show(FragmentManager manager, String tag) { if (manager.findFragmentByTag(tag) == null) { super.show(manager, tag); } }