本文整理汇总了Java中com.google.android.gms.cast.Cast.ApplicationConnectionResult方法的典型用法代码示例。如果您正苦于以下问题:Java Cast.ApplicationConnectionResult方法的具体用法?Java Cast.ApplicationConnectionResult怎么用?Java Cast.ApplicationConnectionResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.cast.Cast
的用法示例。
在下文中一共展示了Cast.ApplicationConnectionResult方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onResult
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
@Override
public void onResult(Cast.ApplicationConnectionResult result) {
if (mState != STATE_LAUNCHING_APPLICATION
&& mState != STATE_API_CONNECTION_SUSPENDED) {
throwInvalidState();
}
Status status = result.getStatus();
if (!status.isSuccess()) {
Log.e(TAG, "Launch application failed with status: %s, %d, %s",
mSource.getApplicationId(), status.getStatusCode(), status.getStatusMessage());
reportError();
}
mState = STATE_LAUNCH_SUCCEEDED;
reportSuccess(result);
}
示例2: reportSuccess
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private void reportSuccess(Cast.ApplicationConnectionResult result) {
if (mState != STATE_LAUNCH_SUCCEEDED) throwInvalidState();
CastSession session = new CastSessionImpl(
mApiClient,
result.getSessionId(),
result.getApplicationMetadata(),
result.getApplicationStatus(),
mSink.getDevice(),
mOrigin,
mTabId,
mIsIncognito,
mSource,
mRouteProvider);
mCastListener.setSession(session);
mRouteProvider.onSessionCreated(session);
terminate();
}
示例3: onResult
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
@Override
public void onResult(Cast.ApplicationConnectionResult result) {
if (mState != STATE_LAUNCHING_APPLICATION) throwInvalidState();
Status status = result.getStatus();
if (!status.isSuccess()) {
reportError(String.format(
ERROR_NEW_ROUTE_LAUNCH_APPLICATION_FAILED_STATUS,
mMediaSource.getApplicationId(),
status.getStatusCode(),
status.getStatusMessage()));
}
mState = STATE_LAUNCH_SUCCEEDED;
reportSuccess(result.getSessionId(), result.getWasLaunched());
}
示例4: onResult
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
@Override
public void onResult(Cast.ApplicationConnectionResult result) {
if (mState != STATE_LAUNCHING_APPLICATION
&& mState != STATE_API_CONNECTION_SUSPENDED) {
throwInvalidState();
}
Status status = result.getStatus();
if (!status.isSuccess()) {
Log.e(TAG, "Launch application failed with status: %s, %d, %s",
mSource.getApplicationId(), status.getStatusCode(), status.getStatusMessage());
reportError();
return;
}
mState = STATE_LAUNCH_SUCCEEDED;
reportSuccess(result);
}
示例5: ConnectionCallbacks
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
ConnectionCallbacks(boolean isPlaying, int position) {
this.isPlaying = isPlaying;
this.position = position;
resultCallback = new ResultCallback<Cast.ApplicationConnectionResult>() {
@Override
public void onResult(Cast.ApplicationConnectionResult result) {
Status status = result.getStatus();
if (status.isSuccess()) {
ApplicationMetadata applicationMetadata = result.getApplicationMetadata();
sessionId = result.getSessionId();
String applicationStatus = result.getApplicationStatus();
boolean wasLaunched = result.getWasLaunched();
applicationStarted = true;
setupChannel();
} else {
shutdownInternal();
}
}
};
}
示例6: verifyPlayMedia
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private com.google.android.gms.cast.MediaInfo verifyPlayMedia(MediaInfo mediaInfo) throws CastService.CastClientException {
setServiceConnected();
MediaPlayer.LaunchListener listener = Mockito.mock(MediaPlayer.LaunchListener.class);
PendingResult<Cast.ApplicationConnectionResult> pendingResult
= Mockito.mock(PendingResult.class);
Mockito.when(castClient.launchApplication(Mockito.any(GoogleApiClient.class),
Mockito.anyString(), Mockito.any(LaunchOptions.class)))
.thenReturn(pendingResult);
// playMedia
service.playMedia(mediaInfo, false, listener);
Robolectric.runUiThreadTasksIncludingDelayedTasks();
// CastApi.launchApplication
Mockito.verify(castClient).launchApplication(Mockito.same(googleApiClient), Mockito.anyString(), Mockito.any(LaunchOptions.class));
// ResultCallback.setResultCallback
ArgumentCaptor<ResultCallback> argResultCallback =
ArgumentCaptor.forClass(ResultCallback.class);
Mockito.verify(pendingResult).setResultCallback(argResultCallback.capture());
// ApplicationConnectionResultCallback.onResult
ResultCallback resultCallback = argResultCallback.getValue();
Cast.ApplicationConnectionResult result = Mockito.mock(Cast.ApplicationConnectionResult.class);
Status status = Mockito.mock(Status.class);
Mockito.when(status.isSuccess()).thenReturn(Boolean.TRUE);
Mockito.when(result.getStatus()).thenReturn(status);
ApplicationMetadata applicationMetadata = Mockito.mock(ApplicationMetadata.class);
Mockito.when(result.getApplicationMetadata()).thenReturn(applicationMetadata);
resultCallback.onResult(result);
Robolectric.runUiThreadTasksIncludingDelayedTasks();
// loadMedia
ArgumentCaptor<com.google.android.gms.cast.MediaInfo> argMedia =
ArgumentCaptor.forClass(com.google.android.gms.cast.MediaInfo.class);
Mockito.verify(mediaPlayer).load(Mockito.same(googleApiClient), argMedia.capture(), Mockito.eq(true));
return argMedia.getValue();
}
示例7: launchApplication
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private PendingResult<Cast.ApplicationConnectionResult> launchApplication(
GoogleApiClient apiClient,
String appId,
boolean relaunchIfRunning) {
LaunchOptions.Builder builder = new LaunchOptions.Builder();
return Cast.CastApi.launchApplication(apiClient, appId,
builder.setRelaunchIfRunning(relaunchIfRunning)
.build());
}
示例8: connectCastDevice
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private void connectCastDevice(boolean forceRelaunch) {
final CastDevice selectedDevice = mCastDeviceHolder.getCastDevice();
Timber.d("acquiring a connection to Google Play services for %s", selectedDevice);
Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions.builder(selectedDevice, new CastListener())
.setVerboseLoggingEnabled(true);
mApiClient = new GoogleApiClient.Builder(mContext)
.addApi(Cast.API, apiOptionsBuilder.build())
//XXX will deadlock, instead we repost callbacks to the handler
// .setHandler(mCallbackHandler)
.build();
ConnectionResult res = mApiClient.blockingConnect();
if (!res.isSuccess()) {
stopWithError(res.getErrorMessage());
return;
}
String applicationId = mContext.getString(R.string.cast_id);
LaunchOptions.Builder launchOptions = new LaunchOptions.Builder()
.setRelaunchIfRunning(forceRelaunch);
Cast.ApplicationConnectionResult castRes;
int retries = 0;
do {
Timber.d("launching cast application try %d", retries);
castRes = Cast.CastApi.launchApplication(mApiClient, applicationId,
launchOptions.build()).await(30, TimeUnit.SECONDS);
launchOptions.setRelaunchIfRunning(false);
} while (!castRes.getStatus().isSuccess() && retries++ < 3);
if (!castRes.getStatus().isSuccess()) {
stopWithError(castRes.getStatus().getStatusMessage());
mSessionId = null;
return;
}
mSessionId = castRes.getSessionId();
attachMediaChannel();
}
示例9: launchApplication
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private PendingResult<Cast.ApplicationConnectionResult> launchApplication(
GoogleApiClient apiClient,
String appId,
boolean relaunchIfRunning) {
return Cast.CastApi.launchApplication(apiClient, appId, relaunchIfRunning);
}
示例10: joinApplication
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
@Override
public PendingResult<Cast.ApplicationConnectionResult> joinApplication(GoogleApiClient client) {
return null;
}
示例11: launchApplication
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
@Override
public PendingResult<Cast.ApplicationConnectionResult> launchApplication(GoogleApiClient client, String applicationId, LaunchOptions launchOptions) {
return null;
}