android - Any idea why setting the background in custom notification using an attribute resource crashes? -
i'm trying set background color of custom notification main layout color depending of selected theme:
android:background="?attr/actionbar_background"
it makes app crashes. if replace 'fixed' color works fine:
android:background="@color/actionbar_background_back"
attr/actionbar_background correctly defined because i'm using in other layouts , works fine
here's stacktrace i'm getting:
android.app.remoteserviceexception: bad notification posted package com.xxx.yyy: couldn't expand remoteviews for: statusbarnotification(pkg=com.xxx.yyy user=userhandle{0} id=1000001 tag=null score=10 key=0|com.xxx.yyy|1000001|null|10582: notification(pri=1 contentview=com.xxx.yyy/0x7f03003f vibrate=null sound=null defaults=0x0 flags=0x62 color=0x00000000 category=transport vis=public))
is android limitation ?
try this:
- define new style on styles.xml
<style android:name="myremotestyle" parent="@style/yourparenttheme"> <item name="android:background">?attr/actionbar_background </item> </style>
- remove android:background part of xml , put instead:
style="@style/myremotestyle"