Invalid Android payload type

After a new update, I found a compatibility issue with spannable / formatted strings in action bars and LG devices.

Here is my code before:

SpannableString s = new SpannableString("About"); s.setSpan(new TypefaceSpan(this, "Sansation-Regular.ttf"), 0, s.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); getSupportActionBar().setTitle(s); 

I believe in setTitle when it crashes and gives this error:

 java.lang.IllegalArgumentException: Invalid payload item type at android.util.EventLog.writeEvent(Native Method) 

Will this fix any potential problems? I am new to Android, so I don’t know. Since the problem seems to only happen with LG devices running on 4.1.2 using actionbarcompat, but since I plan to add support for lower API levels in the future, I really don't want to get rid of actionbarcompat.

 SpannableString s = new SpannableString("About"); s.setSpan(new TypefaceSpan(this, "Sansation-Regular.ttf"), 0, s.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); try{ getSupportActionBar().setTitle(s); }catch(IllegalArgumentException e) { getSupportActionBar().setTitle("About"); } 

Thanks.

PS: The device is in doubt - LG works 4.1.2

+8
android android-actionbar-compat
source share
1 answer

Apparently this is a bug in Android itself. It is fixed with the following commit:

 commit 332944f8a0a001c1754ce3298edbb4246e53c8fb Author: zobject <zbjection@gmail.com> Date: Mon Dec 10 22:52:59 2012 +0900 Fix EventLog string class problem in onOptionMenuSelected EventLog function can handle string,integer class and long class. (in android_util_EventLog.cpp) If menu title string are used bold tag(like <b>test</b>), it'll be android.text.SpannedString. In onOptionMenuSelected, it is using item.getTitleCondensed() function for writing event log. therefore any android activity using tag menu string(like <b></b>) can be crashed by IllegalArgumentException. I found this crash on GMS Application. change locale chinese -> launch Google+ -> hangout -> menu key -> Invite(expressed chinese) click -> Google+ crash Change-Id: I0437be81699925e29bf4510eb615ef2424432763 
+5
source share

All Articles