Code example for MediaRouter.RouteInfo

Methods: getPresentationDisplay, isEnabled

0
  private void handleRoute(RouteInfo route) {
    if (route == null) {
      clearPreso(); 
    } 
    else { 
      Display display=route.getPresentationDisplay();
 
      if (route.isEnabled() && display != null) {
        if (preso == null) {
          showPreso(route);
          Log.d(getClass().getSimpleName(), "enabled route");
        } 
        else if (preso.getDisplay().getDisplayId() != display.getDisplayId()) {
          clearPreso(); 
          showPreso(route);
          Log.d(getClass().getSimpleName(), "switched route");
        } 
        else { 
          // no-op: should already be set 
        } 
      } 
      else { 
        clearPreso(); 
        Log.d(getClass().getSimpleName(), "disabled route");
      } 
    } 
  } 
 
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
  private void clearPreso() { 
    if (preso != null) {
      preso.dismiss();
      preso=null;
    } 
  } 
 
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
  private void showPreso(RouteInfo route) {
    preso=new SimplePresentation(this, route.getPresentationDisplay());
    preso.show();
  } 
 
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  private class RouteCallback extends SimpleCallback {
Contextual code suggestions in your IDE  Get Codota for Java