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

Android 13及以上设备audio_service通知图标不可见问题求助

Android 13+下audio_service自定义通知图标不显示的解决办法

问题排查与修复步骤

1. 符合Android 13的通知图标规范

Android 13开始对通知图标有强制要求:

  • 必须是**单色(仅白色/透明)**资源,带颜色的图标会被系统强制转色,不符合规范的直接不显示。
  • 别只把图标放drawable根目录,要按屏幕密度分文件夹存放(比如drawable-hdpi、drawable-xhdpi等),尺寸参考官方建议:48x48(mdpi)、72x72(hdpi)、96x96(xhdpi)、144x144(xxhdpi)、192x192(xxxhdpi)。

2. 检查图标引用是否正确

  • androidIcon只传不带扩展名的资源名,比如图标文件是ic_custom_pause.png,就写"ic_custom_pause",不要加.png或者@drawable/前缀。
  • 用Android Studio的Analyze APK功能检查APK里的res/drawable目录有没有目标图标,确认资源被正确打包。

3. 调整MediaControl配置或原生渠道设置

如果直接传androidIcon无效,试试两种方式:

  • 确保MediaControl的参数配置完整:
MediaControl(
  androidIcon: "ic_custom_play",
  label: "播放",
  action: MediaAction.play,
)
  • 在Android原生代码里配置通知渠道图标(MainActivity中):
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        val channel = NotificationChannel(
            "audio_playback_channel",
            "音频播放",
            NotificationManager.IMPORTANCE_LOW
        ).apply {
            setShowBadge(false)
            sound = null
            icon = R.drawable.ic_custom_play
        }
        getSystemService(NotificationManager::class.java).createNotificationChannel(channel)
    }
}

4. 更新audio_service到最新版本

旧版本的audio_service可能没适配Android 13的通知规则,在pubspec.yaml里更新依赖:

dependencies:
  audio_service: ^0.18.11 # 替换为当前最新版本

5. 清除缓存后重装测试

设备缓存的旧资源可能干扰显示,先清掉应用的缓存数据,再重新安装APK测试。

内容的提问来源于stack exchange,提问作者Jubair Samir

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 06:05:03