0

我正在使用CastRemoteDisplay(Cast SDK v2)开发一个 Android 应用程序。当另一个应用程序开始投射时,我想确保我的应用程序停止投射,因此我CastOptionsBuilder使用以下侦听器创建我的应用程序:

Cast.Listener listener = new Cast.Listener() {
    @Override
    public void onApplicationMetadataChanged(ApplicationMetadata metadata) {
        String backdropId = "E8C28D3C"; // id of the Cast backdrop app
        if (!(metadata == null
            || metadata.getApplicationId().equals(backdropId)
            || metadata.getApplicationId().equals(MY_APP_ID)) {
            mMediaRouter.unselect(MediaRouter.UNSELECT_REASON_STOPPED);
        }
    }
};

然后设置GoogleApiClient

GoogleApiClient client = (new GoogleApiClient.Builder(this, callbacks, connectFailListener))
                .addApi(CastRemoteDisplay.API, castRemoteDisplayOptionsBuilder.build())
                .addApi(Cast.API, castOptionsBuilder.build())
                .build();

我的问题:是否允许同时CastRemoteDisplay.API使用Cast.API两者GoogleApiClient

4

0 回答 0