How to build music controller in NotificationBar/LockScreen that supporting from api version 10?(如何在NotificationBar/LockScreen中构建从API版本10开始支持的音乐控制器?)
问题描述
我正在构建一个音乐播放器应用程序。我想在通知栏中实现媒体控制器。我尝试了一种方法http://www.binpress.com/tutorial/using-android-media-style-notifications-with-media-session-controls/165。但它只支持棒棒糖版本的Android。有没有人有在通知栏中构建媒体控制器的想法?
推荐答案
您必须对MediaStyle使用通知比较:https://developer.android.com/reference/android/support/v7/app/NotificationCompat.MediaStyle.html
Notification noti = new NotificationCompat.Builder()
.setSmallIcon(R.drawable.ic_stat_player)
.setContentTitle("Track title")
.setContentText("Artist - Album")
.setLargeIcon(albumArtBitmap))
.setStyle(new NotificationCompat.MediaStyle()
.setMediaSession(mySession))
.build();
可以在此处找到使用NotificationCompat实现mediaSessionCompat的完整示例:https://bitbucket.org/nonameden/android-universalmusicplayer-compat/src/412465d6605fee26f197cc5615f7da15cc859d4a/mobile/src/main/java/com/example/android/uamp/MediaNotificationManager.java?at=master
这篇关于如何在NotificationBar/LockScreen中构建从API版本10开始支持的音乐控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在NotificationBar/LockScreen中构建从API版本10开始支持的音乐控制器?


- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01