You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android如何移除通知折叠箭头 让ExoPlayer音频通知始终展开

可以实现让媒体通知始终保持展开状态、移除下拉切换箭头,具体实现方案分两种场景:

基于ExoPlayer官方PlayerNotificationManager的实现

如果你使用ExoPlayer自带的PlayerNotificationManager组件构建通知,可以通过强制统一折叠/展开状态的布局来实现效果:

  • 先将通知优先级设置为最高,避免系统主动将你的媒体通知折叠
  • 监听通知构建过程,直接把折叠态的布局替换为展开态的布局,两个状态布局完全一致就不会出现切换箭头
    代码示例:
playerNotificationManager.apply {
    // 设置最高通知优先级
    setPriority(NotificationCompat.PRIORITY_MAX)
    // 标记为前台服务常驻通知
    setOngoing(true)
    setNotificationListener(object : PlayerNotificationManager.NotificationListener {
        override fun onNotificationPosted(
            notificationId: Int,
            notification: Notification,
            ongoing: Boolean
        ) {
            super.onNotificationPosted(notificationId, notification, ongoing)
            // Android 7.0及以上系统直接复用展开态布局作为默认显示布局
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                notification.contentView = notification.bigContentView
            }
        }
    })
}

自定义通知布局的实现

如果你没有使用ExoPlayer的通知组件,是自行实现通知布局:

  • 给Notification设置NotificationCompat.DecoratedMediaCustomViewStyle样式
  • 将setCustomContentView(折叠态布局)和setCustomBigContentView(展开态布局)设置为同一个布局即可,系统不会生成折叠切换的下拉箭头

适配说明

部分国内厂商定制ROM会强制要求媒体通知支持折叠操作,这种场景下无法完全屏蔽下拉箭头,属于系统级限制,无法通过应用层代码修改。

内容的提问来源于stack exchange,提问作者Ali Akram

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 16:39:03