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
android android-actionbar-compat
Jerryl15
source share