Android Google Cast Notification disable

﹥>﹥吖頭↗ 提交于 2020-06-13 06:11:08

问题


I integrated Google cast to my Android app. All my content is playing via service with notification. When I play media using Google cast it add own notification. Is it possible to disable default google cast notification and use only own notification? Thank you.


回答1:


This is great portal, you ask some question, than you answer own qustion by yourself :)

To disable cast notification needed just to pass null while for setNotificationOptions() in class CastOptionsProvider.

Complete answer:

public class CastOptionsProvider implements OptionsProvider {

    @Override
    public CastOptions getCastOptions(Context context) {

        CastMediaOptions mediaOptions = new CastMediaOptions.Builder().setNotificationOptions(null).build();
        return new CastOptions.Builder().setReceiverApplicationId(context.getString(R.string.app_id)).setCastMediaOptions(mediaOptions).build();
    }

    @Override
    public List<SessionProvider> getAdditionalSessionProviders(Context context) {
        return null;
    }
}


来源:https://stackoverflow.com/questions/60754783/android-google-cast-notification-disable

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