android 11 媒体播放器通知问题

问题描述

我有一个有声读物应用程序,在 android 11 之前可以正常工作。 我的问题是当我将 mediasession 设置为 mediastyle 时,应用程序媒体通知将不再显示。 我找不到问题。

这是我的代码

Notification notification = new NotificationCompat.Builder(this,channelId)
            .setLargeIcon(Archive.Cover)
            .setSmallIcon(R.drawable.ic_small)
            .setContentTitle(Archive.getChapterTitle())
            .setContentText(Archive.BookTitle)
            .setongoing(false)
            .setShowWhen(false)
            .setContentIntent(pendingIntent)
            .setPriority(Notification.PRIORITY_MAX)
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .addAction(generateAction(R.drawable.ic_replay_white_36dp,"Rewind",ACTION_REWIND))
            .addAction(action)
            .addAction(generateAction(R.drawable.ic_forward_white_36dp,"Fast Forward",ACTION_FAST_FORWARD))
            .setStyle(new androidx.media.app.NotificationCompat.MediaStyle()
                    .setMediaSession(mediaSession.getSessionToken())
                    .setShowActionsInCompactView(0,1,2))
            .build();

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)