com.google.android.gms.cast.CastStatusCodes Java Examples

The following examples show how to use com.google.android.gms.cast.CastStatusCodes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CreateRouteRequest.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onApplicationDisconnected(int errorCode) {
    if (errorCode != CastStatusCodes.SUCCESS) {
        Log.e(TAG, String.format(
                "Application disconnected with: %d", errorCode));
    }

    // This callback can be called more than once if the application is stopped from Chrome.
    if (mSession == null) return;

    mSession.stopApplication();
    mSession = null;
}
 
Example #2
Source File: CreateRouteRequest.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
// TODO(crbug.com/635567): Fix this properly.
@SuppressLint("DefaultLocale")
public void onApplicationDisconnected(int errorCode) {
    if (errorCode != CastStatusCodes.SUCCESS) {
        Log.e(TAG, String.format(
                "Application disconnected with: %d", errorCode));
    }

    // This callback can be called more than once if the application is stopped from Chrome.
    if (mSession == null) return;

    mSession.stopApplication();
    mSession = null;
}
 
Example #3
Source File: CreateRouteRequest.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
// TODO(crbug.com/635567): Fix this properly.
@SuppressLint("DefaultLocale")
public void onApplicationDisconnected(int errorCode) {
    if (errorCode != CastStatusCodes.SUCCESS) {
        Log.e(TAG, String.format(
                "Application disconnected with: %d", errorCode));
    }

    // This callback can be called more than once if the application is stopped from Chrome.
    if (mSession == null) return;

    mSession.stopApplication();
    mSession = null;
}
 
Example #4
Source File: VideoCastManager.java    From android with Apache License 2.0 4 votes vote down vote up
@Override
public void onApplicationConnectionFailed(int errorCode) {
    LOGD(TAG, "onApplicationConnectionFailed() reached with errorCode: " + errorCode);
    if (mReconnectionStatus == ReconnectionStatus.IN_PROGRESS) {
        if (errorCode == CastStatusCodes.APPLICATION_NOT_RUNNING) {
            // while trying to re-establish session, we
            // found out that the app is not running so we need
            // to disconnect
            mReconnectionStatus = ReconnectionStatus.INACTIVE;
            onDeviceSelected(null);
        }
        return;
    } else {
        boolean showError = false;
        synchronized (mVideoConsumers) {
            for (IVideoCastConsumer consumer : mVideoConsumers) {
                try {
                    showError = showError || consumer.onApplicationConnectionFailed(errorCode);
                } catch (Exception e) {
                    LOGE(TAG, "onApplicationLaunchFailed(): Failed to inform " + consumer, e);
                }
            }
        }
        if (showError) {
            switch (errorCode) {
                case CastStatusCodes.APPLICATION_NOT_FOUND:
                    LOGD(TAG, "onApplicationConnectionFailed(): failed due to: " +
                            "ERROR_APPLICATION_NOT_FOUND");
                    Utils.showErrorDialog(mContext, R.string.failed_to_find_app);
                    break;
                case CastStatusCodes.TIMEOUT:
                    LOGD(TAG, "onApplicationConnectionFailed(): failed due to: ERROR_TIMEOUT");
                    Utils.showErrorDialog(mContext, R.string.failed_app_launch_timeout);
                    break;
                default:
                    LOGD(TAG, "onApplicationConnectionFailed(): failed due to: errorcode="
                            + errorCode);
                    Utils.showErrorDialog(mContext, R.string.failed_to_launch_app);
                    break;
            }
        }

        onDeviceSelected(null);
        if (null != mMediaRouter) {
            mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
        }
    }
}
 
Example #5
Source File: VideoCastManager.java    From UTubeTV with The Unlicense 4 votes vote down vote up
@Override
public void onApplicationConnectionFailed(int errorCode) {
  CastUtils.LOGD(TAG, "onApplicationConnectionFailed() reached with errorCode: " + errorCode);
  if (mReconnectionStatus == ReconnectionStatus.IN_PROGRESS) {
    if (errorCode == CastStatusCodes.APPLICATION_NOT_RUNNING) {
      // while trying to re-establish session, we
      // found out that the app is not running so we need
      // to disconnect
      mReconnectionStatus = ReconnectionStatus.INACTIVE;
      onDeviceSelected(null);
    }
  } else {
    boolean showError = false;
    for (IVideoCastConsumer consumer : mVideoConsumers) {
      try {
        showError = showError || consumer.onApplicationConnectionFailed(errorCode);
      } catch (Exception e) {
        CastUtils.LOGE(TAG, "onApplicationLaunchFailed(): Failed to inform " + consumer, e);
      }
    }
    if (showError) {
      switch (errorCode) {
        case CastStatusCodes.APPLICATION_NOT_FOUND:
          CastUtils.LOGD(TAG, "onApplicationConnectionFailed(): failed due to: " + "ERROR_APPLICATION_NOT_FOUND");
          CastUtils.showErrorDialog(mContext, R.string.failed_to_find_app);
          break;
        case CastStatusCodes.TIMEOUT:
          CastUtils.LOGD(TAG, "onApplicationConnectionFailed(): failed due to: ERROR_TIMEOUT");
          CastUtils.showErrorDialog(mContext, R.string.failed_app_launch_timeout);
          break;
        default:
          CastUtils.LOGD(TAG, "onApplicationConnectionFailed(): failed due to: errorcode=" + errorCode);
          CastUtils.showErrorDialog(mContext, R.string.failed_to_launch_app);
          break;
      }
    }

    onDeviceSelected(null);
    if (null != mMediaRouter) {
      mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
    }
  }
}