Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RemoteServiceException when notification style is applied on Xiaomi phones with Android 11

Without any visible reason, Xiaomi phones with Android 11 started to appear in crashlytics logs. Something happens with notifications. We don't do anything too specific and everything works fine on other Android 11 devices. I wasn't able to reproduce this crash on the affected device. What could be the reason?

First crashes started to appear at the beginning of December, and the amount rapidly grow through January from 10 per day to 100+

crash:

Fatal Exception: android.app.RemoteServiceException
Bad notification(tag=null, id=) posted from package my.application, crashing app(uid=, pid=): Couldn't inflate contentViewsjava.lang.ClassCastException: android.app.Notification$MediaStyle cannot be cast to android.app.Notification$MessagingStyle

Notification style:

    final MediaStyle style = new MediaStyle()
            .setMediaSession(token)
            .setShowActionsInCompactView(PREV_POSITION, PLAY_PAUSE_POSITION, NEXT_POSITION)
            .setCancelButtonIntent(STOP.notificationPending(mContext))
            .setShowCancelButton(true);
    setStyle(style);
like image 604
Maksim Turaev Avatar asked Feb 12 '21 13:02

Maksim Turaev


Video Answer


1 Answers

Same problem here. I think this is a bug from MIUI instead of the bug from the app. MIUI changes the notification part a lot for their own look and feel. It may be fixed in future MIUI updates.

like image 140
Hexise Avatar answered Oct 19 '22 05:10

Hexise