[尝试构建一个实时流媒体播放应用程序,SDK在28及以下的媒体样式通知看起来不错,没有任何搜索栏,但是在Android 10(SDK 29)中运行同一应用程序时,该通知显示了其他搜索栏,但我没有想要,因为流是实时的,并且我正在使用默认的exoplayer(exo vers。2.10.8)行为进行缓存。
如何禁用或隐藏搜索栏?
下面的通知构建器中的尝试设置:
。setProgress(0,0,true)
下面的通知摘要:
Notification notification = new Notification.Builder(this,Constant.CHANNEL_ID)
.setSmallIcon(R.drawable.ic_logo)
.setContentTitle(title)
.setContentText(message)
.setLargeIcon(artwork)
.addAction(new Notification.Action.Builder(
Icon.createWithResource(getApplicationContext(),playPauseResourceId),
"Play/Pause",
playPausePendingIntent).build())
.addAction(new Notification.Action.Builder(
Icon.createWithResource(getApplicationContext(),R.drawable.exo_icon_stop),
"Play/Pause",
stopPendingIntent).build())
.setStyle(new Notification.MediaStyle().setShowActionsInCompactView(0).setMediaSession(mediaSession.getSessionToken()))
.setSubText(subText)
.setContentIntent(pendingActivityIntent)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setProgress(0,0,true)
.build();
Screeshot:
PlayerNotificationManager
而不是Notification.Builder
,并使用Bundle
键和MediaDescriptionCompat.Builder
值使用setExtras()
方法将自定义MediaMetadataCompat.METADATA_KEY_DURATION
额外传递给-1
,然后覆盖getMediaDescription()
的TimelineQueueNavigator
方法类,然后将其传递给MediaSessionConnector
: