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

前端 未结 15 1861
执笔经年
执笔经年 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 07:02

    Generally,this error means your contentView is error,check it ! maybe you'd better replace your contentView with a layout that contain a TextView only.Ok,run it,hope help for you.

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

    For me the problem was having a View item in the custom layout set for the custom notification. Removing the View item from the layout solved the problem of the Bad Notification Posted.

    Here's a list of layout items which can be used, if you want to create a custom notification using RemoteView.

    Neither cleaning project nor setting the layout_height as match_parent worked for me.

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

    Don't use XML vector drawables for older android versions. It will crash the app. Use PNGs

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

    for unknown reason you are not allowed to reference dimention in the root view of the custom remote view! so you have to hard code it like android:layout_height="64dp" but if you used android:layout_height="@dimen/notification_height_that_64" it will give you Bad notification posted - Couldn't expand RemoteViews for: StatusBarNotification . i hope this will help :)

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

    For me, the problem was that I was setting a specific height for the root layout, in the custom notification view xml file.

    As soon as I changed:

    android:layout_height="@dimen/notification_expanded"

    to

    android:layout_height="match_parent"

    in the root layout of notification view, the problem was solved.

    Also take a look at this example to see a simple example of using custom layout for notifications.

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

    In my case, i was able to fix this error by reducing the icon size i was providing into .setSmallIcon();

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