Bad notification posted - Couldn't expand RemoteViews for: StatusBarNotification

前端 未结 15 1859
执笔经年
执笔经年 2020-12-03 06:47

I am trying to post a notification with a custom view in the notification area from an IntentService, and getting the Couldn\'t expand RemoteView e

相关标签:
15条回答
  • 2020-12-03 06:54

    Be careful when using Vector drawables. On pre-Lollipop devices setting an icon through NotificationCompat.Builder methods, like setSmallIcon, will cause this crash. You'll get same crash if using Vector drawables in your custom view.

    0 讨论(0)
  • 2020-12-03 06:57

    I got the same error, but the problem for me was the constrain layout. I changed it to Relative Layout to fix the the problem.

    0 讨论(0)
  • 2020-12-03 06:58

    In my case, the problem was an inconsistency between the call

    setShowActionsInCompactView(0)
    

    And the .addAction calls...The number of actions was different, hence the error

    0 讨论(0)
  • 2020-12-03 07:00

    In my case the exception was caused by a regular View in my custom notification layout. Basically, it's because you're allowed to use only certain widgets like TextView, ImageView and so on.

    0 讨论(0)
  • 2020-12-03 07:00

    I had the same problem. In my case:

    reason -> I used for the builder.setAction(R.drawable.icon,...) function a vectordrawable and I tried also to enable them from support lib but nothing worked. In recent Android systems I do not see action icons, in the others it gives this error.

    solution -> I did not find nothing, the only workaround for me is to avoid .xml files for drawables and to use the .png files in all directories hdpi mdpi ldpi..

    0 讨论(0)
  • 2020-12-03 07:00

    I was facing same issue in showing custom layout in notification and what i found is:

    I was using ConstraintsLayout as a root layout of my custom notification, this is the mistake i was committing. As there are some limitations with constrain layout to be used in android.

    Finally i changed my root layout to RelativeLayout and my notification showing perfectly. I have attached my view in below screenshot.

    0 讨论(0)
提交回复
热议问题