本文整理汇总了Java中com.google.android.gms.cast.CastStatusCodes类的典型用法代码示例。如果您正苦于以下问题:Java CastStatusCodes类的具体用法?Java CastStatusCodes怎么用?Java CastStatusCodes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CastStatusCodes类属于com.google.android.gms.cast包,在下文中一共展示了CastStatusCodes类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onApplicationConnectionFailed
import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@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
import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@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: onApplicationDisconnected
import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@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;
}
示例4: onMediaLoadResult
import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@Override
public void onMediaLoadResult(int statusCode) {
if (CastStatusCodes.SUCCESS != statusCode) {
LOGD(TAG, "onMediaLoadResult(): Failed to load media with status code: "
+ statusCode);
Utils.showToast(getActivity(), R.string.ccl_failed_to_load_media);
mCastController.closeActivity();
}
}
示例5: createRoute
import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
/**
* Initiates route creation with the given parameters. Notifies the native client of success
* and failure.
* @param sourceId the id of the {@link MediaSource} to route to the sink.
* @param sinkId the id of the {@link MediaSink} to route the source to.
* @param presentationId the id of the presentation to be used by the page.
* @param requestId the id of the route creation request tracked by the native side.
*/
@CalledByNative
public void createRoute(
final String sourceId,
final String sinkId,
final String presentationId,
int requestId) {
if (mAndroidMediaRouter == null) {
nativeOnRouteCreationError(mNativeMediaRouterAndroid, "Not supported", requestId);
return;
}
new CreateRouteRequest(sourceId, sinkId, presentationId, requestId, this).start(
mAndroidMediaRouter,
mApplicationContext,
// TODO(avayvod): handle application disconnect and report back to the native side.
// Part of https://crbug.com/517100.
new Cast.Listener() {
@Override
public void onApplicationDisconnected(int errorCode) {
if (errorCode != CastStatusCodes.SUCCESS) {
Log.e(TAG, String.format(
"Application disconnected with: %d", errorCode));
}
closeRoute(createMediaRouteId(presentationId, sinkId, sourceId));
}
});
}
示例6: onApplicationDisconnected
import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@Override
public void onApplicationDisconnected(int statusCode) {
Log.d(TAG, "onApplicationDisconnected: statusCode=" + statusCode);
mAppMetadata = null;
detachMediaPlayer();
clearMediaState();
updateButtonStates();
if (statusCode != CastStatusCodes.SUCCESS) {
// This is an unexpected disconnect.
setApplicationStatus(getString(R.string.status_app_disconnected));
}
}
示例7: disconnectDevice
import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
/**
* 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);
}
示例8: onApplicationConnectionFailed
import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@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());
}
}
}
示例9: handleMessage
import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@Override
public void handleMessage(Message msg) {
BaseActivity activity = reference.get();
if (activity == null) {
Timber.e("CastManagerCallbackHandler: activity was null");
return;
}
switch (msg.what) {
case CAST_APPLICATION_CONNECTION_FAILED:
final String errorMsg;
switch (msg.arg1) {
case CastStatusCodes.APPLICATION_NOT_FOUND:
errorMsg = "ERROR_APPLICATION_NOT_FOUND";
break;
case CastStatusCodes.TIMEOUT:
errorMsg = "ERROR_TIMEOUT";
break;
default:
errorMsg = "UNKNOWN ERROR: " + msg.arg1;
break;
}
Timber.d("onApplicationConnectionFailed(): failed due to: " + errorMsg);
resetDefaultMediaRoute(activity);
// notify if possible
if (activity.mIsResumed) {
new AlertDialog.Builder(activity)
.setTitle(R.string.cast_error)
.setMessage(String.format(Locale.getDefault(),
activity.getString(R.string.cast_failed_to_connect), errorMsg))
.setPositiveButton(android.R.string.ok, null)
.show();
}
break;
case CAST_APPLICATION_DISCONNECTED:
// This is just in case
resetDefaultMediaRoute(activity);
break;
case CAST_CONNECTION_SUSPENDED:
activity.mTransientNetworkDisconnection = true;
break;
case CAST_CONNECTIVITY_RECOVERED:
activity.mTransientNetworkDisconnection = false;
break;
case CAST_DISCONNECTED:
activity.mTransientNetworkDisconnection = false;
break;
case CAST_FAILED:
// notify if possible
if (activity.mIsResumed) {
switch (msg.arg1) {
case (R.string.failed_load):
new AlertDialog.Builder(activity)
.setTitle(R.string.cast_error)
.setMessage(R.string.failed_load)
.setPositiveButton(android.R.string.ok, null)
.show();
break;
}
}
break;
}
}
示例10: onApplicationConnectionFailed
import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@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());
}
}
}
示例11: onApplicationConnectionFailed
import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@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());
}
}
}
示例12: doInBackground
import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@Override
protected MetadataBuffer doInBackground(Void... params) {
// Check connection
if (!mClient.isConnected()) {
errorString = NetpowerctrlApplication.getAppString(R.string.gDrive_error_lost_connection);
return null;
}
try {
// Request sync
com.google.android.gms.common.api.Status resultRequestSync;
resultRequestSync = Drive.DriveApi.requestSync(mClient).await(5, TimeUnit.SECONDS);
if (!resultRequestSync.getStatus().isSuccess()) {
if (resultRequestSync.getStatusCode() == CastStatusCodes.TIMEOUT) {
errorString = NetpowerctrlApplication.getAppString(R.string.gDrive_error_timeout);
} else
errorString = NetpowerctrlApplication.getAppString(R.string.gDrive_error_retrieve_files,
resultRequestSync.getStatus().toString());
// We failed, stop the task and return.
return null;
}
// Enter dir
DriveFolder PluginServiceDir = GDrive.getAppFolder(mClient);
// Get childs
DriveApi.MetadataBufferResult result = PluginServiceDir.listChildren(mClient).await(5, TimeUnit.SECONDS);
if (!result.getStatus().isSuccess()) {
if (resultRequestSync.getStatusCode() == CastStatusCodes.TIMEOUT) {
errorString = NetpowerctrlApplication.getAppString(R.string.gDrive_error_timeout);
} else
errorString = NetpowerctrlApplication.getAppString(R.string.gDrive_error_retrieve_files, result.getStatus().toString());
// We failed, stop the task and return.
return null;
}
return result.getMetadataBuffer();
} catch (Exception e) {
errorString = e.getMessage();
}
return null;
}