本文整理汇总了Java中com.google.android.gms.cast.Cast.Listener方法的典型用法代码示例。如果您正苦于以下问题:Java Cast.Listener方法的具体用法?Java Cast.Listener怎么用?Java Cast.Listener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.cast.Cast
的用法示例。
在下文中一共展示了Cast.Listener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initCastClientListener
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private void initCastClientListener() {
mCastClientListener = new Cast.Listener() {
@Override
public void onApplicationStatusChanged() {
}
@Override
public void onVolumeChanged() {
}
@Override
public void onApplicationDisconnected( int statusCode ) {
teardown();
}
};
}
示例2: initCastClientListener
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private void initCastClientListener() {
mCastClientListener = new Cast.Listener() {
@Override
public void onApplicationStatusChanged() {
}
@Override
public void onVolumeChanged() {
}
@Override
public void onApplicationDisconnected(int statusCode) {
teardown();
}
};
}
示例3: launchReceiver
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
/**
* Start the receiver app
*/
private void launchReceiver() {
try {
mCastListener = new Cast.Listener() {
@Override
public void onApplicationDisconnected(int errorCode) {
Log.d(TAG, "application has stopped");
teardown();
}
};
// Connect to Google Play services
mConnectionCallbacks = new ConnectionCallbacks();
mConnectionFailedListener = new ConnectionFailedListener();
Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions.builder(mSelectedDevice, mCastListener);
mApiClient = new GoogleApiClient.Builder(this).addApi(Cast.API, apiOptionsBuilder.build()).addConnectionCallbacks(mConnectionCallbacks)
.addOnConnectionFailedListener(mConnectionFailedListener).build();
mApiClient.connect();
} catch (Exception e) {
Log.e(TAG, "Failed launchReceiver", e);
}
}
示例4: launchReceiver
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
/**
* Start the receiver app
*/
private void launchReceiver() {
try {
mCastListener = new Cast.Listener() {
@Override
public void onApplicationDisconnected(int errorCode) {
teardown();
}
};
// Connect to Google Play services
mConnectionCallbacks = new ConnectionCallbacks();
mConnectionFailedListener = new ConnectionFailedListener();
Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions.builder(mSelectedDevice, mCastListener);
mApiClient = new GoogleApiClient.Builder(this).addApi(Cast.API, apiOptionsBuilder.build())
.addConnectionCallbacks(mConnectionCallbacks)
.addOnConnectionFailedListener(mConnectionFailedListener).build();
mApiClient.connect();
} catch (Exception e) {
Log.e(TAG, "Failed launchReceiver", e);
}
}
示例5: createApiClient
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private GoogleApiClient createApiClient(Cast.Listener listener, Context context) {
Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions
.builder(mSink.getDevice(), listener)
// TODO(avayvod): hide this behind the flag or remove
.setVerboseLoggingEnabled(true);
return new GoogleApiClient.Builder(context)
.addApi(Cast.API, apiOptionsBuilder.build())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
示例6: launchReceiver
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private void launchReceiver() {
try {
mCastListener = new Cast.Listener() {
@Override
public void onApplicationDisconnected(int errorCode) {
Log.d(TAG, "application has stopped");
//tearDownReceiver(true);
}
};
// Connect to Google Play services
mConnectionCallbacks = new PinCastConnectionCallbacks();
mConnectionFailedListener = new PinCastConnectionFailedListener();
Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions
.builder(mSelectedDevice, mCastListener);
mApiClient = new GoogleApiClient.Builder(this)
.addApi(Cast.API, apiOptionsBuilder.build())
.addConnectionCallbacks(mConnectionCallbacks)
.addOnConnectionFailedListener(mConnectionFailedListener)
.build();
mApiClient.connect();
} catch (Exception e) {
Log.e(TAG, "Failed launchReceiver", e);
}
}
示例7: start
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
/**
* Starts the process of launching the application on the Cast device.
* @param androidMediaRouter Android's {@link MediaRouter} instance.
* @param applicationContext application context
* @param castApplicationListener {@link com.google.android.gms.cast.Cast.Listener}
* implementation provided by the caller.
*/
public void start(
MediaRouter androidMediaRouter,
Context applicationContext,
Cast.Listener castApplicationListener) {
assert androidMediaRouter != null;
assert applicationContext != null;
assert castApplicationListener != null;
if (mState != STATE_IDLE) throwInvalidState();
if (mMediaSource == null) {
reportError(String.format(ERROR_NEW_ROUTE_INVALID_SOURCE_URN, mSourceUrn));
return;
}
mRoute = null;
for (MediaRouter.RouteInfo route : androidMediaRouter.getRoutes()) {
MediaSink routeSink = MediaSink.fromRoute(route);
if (routeSink.getId().equals(mSinkId)) {
mRoute = route;
break;
}
}
if (mRoute == null) {
reportError(String.format(ERROR_NEW_ROUTE_INVALID_SINK_URN, mSinkId));
return;
}
mApiClient = createApiClient(mRoute, castApplicationListener, applicationContext);
mApiClient.connect();
mState = STATE_CONNECTING_TO_API;
}
示例8: createApiClient
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private GoogleApiClient createApiClient(
MediaRouter.RouteInfo route, Cast.Listener listener, Context context) {
CastDevice selectedDevice = CastDevice.getFromBundle(route.getExtras());
Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions
.builder(selectedDevice, listener)
// TODO(avayvod): hide this behind the flag or remove
.setVerboseLoggingEnabled(true);
return new GoogleApiClient.Builder(context)
.addApi(Cast.API, apiOptionsBuilder.build())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
示例9: connect
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
/**
* GooglePlayServiceに接続し、Receiverアプリケーションを起動する.
*
*/
public void connect() {
if (mApiClient != null && mIsApplicationDisconnected) {
mIsApplicationDisconnected = false;
launchApplication();
}
if (mApiClient == null) {
mIsApplicationDisconnected = false;
mCastListener = new Cast.Listener() {
@Override
public void onApplicationDisconnected(final int statusCode) {
if (BuildConfig.DEBUG) {
Log.d(TAG, "onApplicationDisconnected$statusCode: " + statusCode);
}
mIsApplicationDisconnected = true;
}
@Override
public void onApplicationStatusChanged() {
if (BuildConfig.DEBUG) {
Log.d(TAG, "onApplicationStatusChanged");
}
}
};
Cast.CastOptions.Builder apiOptionsBuilder =
Cast.CastOptions.builder(mSelectedDevice, mCastListener);
mApiClient = new GoogleApiClient.Builder(mContext)
.addApi(Cast.API, apiOptionsBuilder.build())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
mApiClient.connect();
}
}
示例10: onRouteSelected
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
@Override
public void onRouteSelected(MediaRouter router, MediaRouter.RouteInfo info) {
mSelectedDevice = CastDevice.getFromBundle(info.getExtras());
// Step 12
mCastClientListener = new Cast.Listener() {
@Override
public void onApplicationStatusChanged() {
if (mApiClient != null) {
Log.d(TAG, "onApplicationStatusChanged: " + Cast.CastApi.getApplicationStatus(mApiClient));
}
}
@Override
public void onVolumeChanged() {
}
@Override
public void onApplicationDisconnected(int errorCode) {
teardown();
}
};
// Step 9
mConnectionCallbacks = new ConnectionCallbacks();
mConnectionFailedListener = new ConnectionFailedListener();
Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions.builder(mSelectedDevice, mCastClientListener);
mApiClient = new GoogleApiClient.Builder(getApplicationContext()).addApi(Cast.API, apiOptionsBuilder.build()).addConnectionCallbacks(mConnectionCallbacks).addOnConnectionFailedListener(mConnectionFailedListener).build();
// Step 10
if (!mApiClient.isConnected()) {
mApiClient.connect();
}
// Step 15
Cast.CastOptions.builder(mSelectedDevice, mCastClientListener).setVerboseLoggingEnabled(true).build();
}
示例11: createApiClient
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private GoogleApiClient createApiClient(Cast.Listener listener) {
Cast.CastOptions.Builder apiOptionsBuilder =
new Cast.CastOptions.Builder(mSink.getDevice(), listener)
// TODO(avayvod): hide this behind the flag or remove
.setVerboseLoggingEnabled(true);
return new GoogleApiClient.Builder(ContextUtils.getApplicationContext())
.addApi(Cast.API, apiOptionsBuilder.build())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
示例12: launchReceiver
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
/**
* Start the receiver app
*/
private void launchReceiver() {
try {
Cast.Listener mCastListener = new Cast.Listener() {
@Override
public void onApplicationDisconnected(int errorCode) {
log("Application has stopped. Error code: " + errorCode);
shutdownConnection();
}
};
// Connect to Google Play services
ConnectionCallbacks mConnectionCallbacks = new ConnectionCallbacks();
ConnectionFailedListener mConnectionFailedListener = new ConnectionFailedListener();
Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions
.builder(mSelectedDevice, mCastListener);
mApiClient = new GoogleApiClient.Builder(context)
.addApi(Cast.API, apiOptionsBuilder.build())
.addConnectionCallbacks(mConnectionCallbacks)
.addOnConnectionFailedListener(mConnectionFailedListener)
.build();
mApiClient.connect();
} catch (Exception e) {
log("Failed launchReceiver");
e.printStackTrace();
}
}
示例13: launchReceiver
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
/**
* Start the receiver app
*/
private void launchReceiver() {
try {
Cast.Listener castListener = new Cast.Listener() {
@Override
public void onApplicationDisconnected(int errorCode) {
Log.d(TAG, "application has stopped");
teardown(true);
}
};
// Connect to Google Play services
ConnectionCallbacks connectionCallbacks = new ConnectionCallbacks();
ConnectionFailedListener connectionFailedListener = new ConnectionFailedListener();
Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions
.builder(mState.selectedDevice, castListener);
mState.apiClient = new GoogleApiClient.Builder(mActivity)
.addApi(Cast.API, apiOptionsBuilder.build())
.addConnectionCallbacks(connectionCallbacks)
.addOnConnectionFailedListener(connectionFailedListener)
.build();
mState.apiClient.connect();
} catch (Exception e) {
Log.e(TAG, "Failed launchReceiver", e);
}
}
示例14: launchReceiver
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
/**
* Start the receiver app
*/
private void launchReceiver() {
try {
mCastListener = new Cast.Listener() {
@Override
public void onApplicationDisconnected(int errorCode) {
Log.d(TAG, "application has stopped");
teardown();
}
};
// Connect to Google Play services
mConnectionCallbacks = new ConnectionCallbacks();
mConnectionFailedListener = new ConnectionFailedListener();
Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions
.builder(mSelectedDevice, mCastListener);
mApiClient = new GoogleApiClient.Builder(this)
.addApi(Cast.API, apiOptionsBuilder.build())
.addConnectionCallbacks(mConnectionCallbacks)
.addOnConnectionFailedListener(mConnectionFailedListener)
.build();
mApiClient.connect();
} catch (Exception e) {
Log.e(TAG, "Failed launchReceiver", e);
}
}
示例15: launchReceiver
import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private void launchReceiver() {
try {
mCastListener = new Cast.Listener() {
@Override
public void onApplicationDisconnected(int errorCode) {
Log.d(TAG, "application has stopped");
// teardown();
}
};
// Connect to Google Play services
mConnectionCallbacks = new ConnectionCallbacks();
mConnectionFailedListener = new ConnectionFailedListener();
Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions
.builder(mSelectedDevice, mCastListener);
mApiClient = new GoogleApiClient.Builder(this)
.addApi(Cast.API, apiOptionsBuilder.build())
.addConnectionCallbacks(mConnectionCallbacks)
.addOnConnectionFailedListener(mConnectionFailedListener)
.build();
mApiClient.connect();
} catch (Exception e) {
Log.e(TAG, "Failed launchReceiver", e);
}
}