Creating a notification for MediaPlayer with an Android Foreground Service

半城伤御伤魂 提交于 2019-12-04 14:12:02

Asking for an authoritative source is a bit difficult in this case, since most music players are closed-source and virtually no one else uses that sort of expanded controls-in-the-view notification.

From a stylistic point of view, I would delegate to NotificationCompat instead of extend it. That way, you can present a simpler API internally as opposed to exposing the whole of NotificationCompat.

As for RemoteViews, I'm not sure what you're asking exactly. However you do it, as long as you keep the Notification instance, you can keep the instance to RemoteViews (or the individual views) and update them as needed. If you go with delegation instead of inheritance, it would be quite a bit cleaner as it makes sense in a "this field is the notification, this field is its Views" kinda way.

P.S. From a purely syntactical point of view, try to use the framework naming guidelines. Most notably, fields are prefixed with 'm' and use camelCase (e.g., mNotifTitle). Lastly, private fields are the kryptonite of good tests.

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