private void sendControlIntent(final Intent intent, final ResultBundleHandler bundleHandler) {
Log.d(TAG, "Sending intent to %s %s", getCurrentRoute().getName(),
getCurrentRoute().getId());
logIntent("sendControlIntent ", intent);
if (getCurrentRoute().isDefault()) {
Log.d(TAG, "Route is default, not sending");
return;
}
getCurrentRoute().sendControlRequest(intent, new MediaRouter.ControlRequestCallback() {
@Override
public void onResult(Bundle data) {
if (data != null && bundleHandler != null) bundleHandler.onResult(data);
}
@Override
public void onError(String message, Bundle data) {
logControlRequestError(intent, message, data);
int errorCode = 0;
if (data != null) {
errorCode = data.getInt(CastMediaControlIntent.EXTRA_ERROR_CODE);
}
sendErrorToListeners(errorCode);
if (bundleHandler != null) bundleHandler.onError(message, data);
}
});
}