小编TR4*_*oid的帖子

使用Google Cast SDK v3进行自定义通知

自从新的Google Cast SDK v3问世以来,我一直在考虑迁移到它,因为它有一些我需要的功能,而且我总是希望尽可能保持最新版本.我以前的设置使用了Google Cast SDK v2 + Cast Companion Library.但是,我一直无法找到在新的Google Cast SDK v3中提供完全自定义通知的方法,这会阻止我使用它.

使用Google Cast SDK v2 + Cast Companion Library,我能够简单地对其进行子类化VideoCastNotificationService并覆盖其build方法以生成自定义通知:

public class MyCastNotificationService extends VideoCastNotificationService {
    @Override
    protected void build(MediaInfo info, Bitmap bitmap, boolean isPlaying) {
        // ... build the custom notification
        mNotification = new NotificationCompat.Builder(this)/*...*/.build();
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我可以注册MyCastNotificationService我的CastConfiguration喜欢这个:

CastConfiguration castConfig = new CastConfiguration.Builder(APPLICATION_ID)
    /*...*/
    .setCustomNotificationService(MyCastNotificationService.class)
    .build();
Run Code Online (Sandbox Code Playgroud)

但是,使用Google Cast SDK v3, …

android google-cast

9
推荐指数
0
解决办法
759
查看次数

标签 统计

android ×1

google-cast ×1