本文整理汇总了Java中com.google.android.gms.cast.CastStatusCodes.APPLICATION_NOT_RUNNING属性的典型用法代码示例。如果您正苦于以下问题:Java CastStatusCodes.APPLICATION_NOT_RUNNING属性的具体用法?Java CastStatusCodes.APPLICATION_NOT_RUNNING怎么用?Java CastStatusCodes.APPLICATION_NOT_RUNNING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.android.gms.cast.CastStatusCodes
的用法示例。
在下文中一共展示了CastStatusCodes.APPLICATION_NOT_RUNNING属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onApplicationConnectionFailed
@Override
public void onApplicationConnectionFailed(int errorCode) {
if (mReconnectionStatus == RECONNECTION_STATUS_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 = RECONNECTION_STATUS_INACTIVE;
onDeviceSelected(null /* CastDevice */, null /* RouteInfo */);
}
} else {
for (DataCastConsumer consumer : mDataConsumers) {
consumer.onApplicationConnectionFailed(errorCode);
}
onDeviceSelected(null /* CastDevice */, null /* RouteInfo */);
if (mMediaRouter != null) {
LOGD(TAG, "onApplicationConnectionFailed(): Setting route to default");
mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
}
}
}
示例2: onApplicationConnectionFailed
@Override
public void onApplicationConnectionFailed(int errorCode) {
LOGD(TAG, "onApplicationConnectionFailed() reached with errorCode: " + errorCode);
mApplicationErrorCode = errorCode;
if (mReconnectionStatus == RECONNECTION_STATUS_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 = RECONNECTION_STATUS_INACTIVE;
onDeviceSelected(null /* CastDevice */, null /* RouteInfo */);
}
} else {
for (VideoCastConsumer consumer : mVideoConsumers) {
consumer.onApplicationConnectionFailed(errorCode);
}
onDeviceSelected(null /* CastDevice */, null /* RouteInfo */);
if (mMediaRouter != null) {
LOGD(TAG, "onApplicationConnectionFailed(): Setting route to default");
mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
}
}
}
示例3: disconnectDevice
/**
* Disconnects from the connected device.
*
* @param stopAppOnExit If {@code true}, the application running on the cast device will be
* stopped when disconnected.
* @param clearPersistedConnectionData If {@code true}, the persisted connection information
* will be cleared as part of this call.
* @param setDefaultRoute If {@code true}, after disconnection, the selected route will be set
* to the Default Route.
*/
public final void disconnectDevice(boolean stopAppOnExit, boolean clearPersistedConnectionData,
boolean setDefaultRoute) {
LOGD(TAG, "disconnectDevice(" + clearPersistedConnectionData + "," + setDefaultRoute + ")");
if (mSelectedCastDevice == null) {
return;
}
mSelectedCastDevice = null;
mDeviceName = null;
String message = "disconnectDevice() Disconnect Reason: ";
int reason;
if (mConnectionSuspended) {
message += "Connectivity lost";
reason = DISCONNECT_REASON_CONNECTIVITY;
} else {
switch (mApplicationErrorCode) {
case CastStatusCodes.APPLICATION_NOT_RUNNING:
message += "App was taken over or not available anymore";
reason = DISCONNECT_REASON_APP_NOT_RUNNING;
break;
case NO_APPLICATION_ERROR:
message += "Intentional disconnect";
reason = DISCONNECT_REASON_EXPLICIT;
break;
default:
message += "Other";
reason = DISCONNECT_REASON_OTHER;
}
}
LOGD(TAG, message);
for (BaseCastConsumer consumer : mBaseCastConsumers) {
consumer.onDisconnectionReason(reason);
}
LOGD(TAG, "mConnectionSuspended: " + mConnectionSuspended);
if (!mConnectionSuspended && clearPersistedConnectionData) {
clearPersistedConnectionInfo(CLEAR_ALL);
stopReconnectionService();
}
try {
if ((isConnected() || isConnecting()) && stopAppOnExit) {
LOGD(TAG, "Calling stopApplication");
stopApplication();
}
} catch (NoConnectionException | TransientNetworkDisconnectionException e) {
LOGE(TAG, "Failed to stop the application after disconnecting route", e);
}
onDeviceUnselected();
if (mApiClient != null) {
// the following check is currently required, without including a check for
// isConnecting() due to a bug in the current play services library and will be removed
// when that bug is addressed; calling disconnect() while we are in "connecting" state
// will throw an exception
if (mApiClient.isConnected()) {
LOGD(TAG, "Trying to disconnect");
mApiClient.disconnect();
}
if ((mMediaRouter != null) && setDefaultRoute) {
LOGD(TAG, "disconnectDevice(): Setting route to default");
mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
}
mApiClient = null;
}
mSessionId = null;
onDisconnected(stopAppOnExit, clearPersistedConnectionData, setDefaultRoute);
}
示例4: onApplicationConnectionFailed
@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, "onApplicationConnectionFailed(): 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) {
LOGD(TAG, "onApplicationConnectionFailed(): Setting route to default");
mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
}
}
}
示例5: onApplicationConnectionFailed
@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());
}
}
}
示例6: onApplicationConnectionFailed
@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());
}
}
}