Can one use CastRemoteDisplay.API and Cast.API on the same GoogleApiClient?

牧云@^-^@ 提交于 2020-03-06 04:34:35

问题


I am developing an Android app with CastRemoteDisplay (Cast SDK v2). When another app starts casting, I want to ensure my app stops casting, so I create my CastOptionsBuilder with the following listener:

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);
        }
    }
};

Then setup the GoogleApiClient with:

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

My question: is it permitted to use both CastRemoteDisplay.API and Cast.API on the same GoogleApiClient?

来源:https://stackoverflow.com/questions/39836864/can-one-use-castremotedisplay-api-and-cast-api-on-the-same-googleapiclient

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!