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
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.
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.
Don't use XML vector drawables for older android versions. It will crash the app. Use PNGs
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 :)
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.
In my case, i was able to fix this error by reducing the icon size i was providing into .setSmallIcon();