本文介绍了无效的有效载荷类型的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的更新之后,我发现,在动作条和LG设备spannable /格式的字符串的兼容性问题。

After a new update, I've discovered an issue with the compatibility of spannable/formatted strings in action bars and LG devices.

下面是我的code面前:

Here's 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);

我相信在是的setTitle崩溃时,给这个错误:

I believe on setTitle is when it crashes and gives this error:

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

这会解决任何潜在的问题?我是新来的Andr​​oid所以不知道。因为这个问题似乎只能用actionbarcompat运行4.1.2 LG的设备可能发生的 - 而是因为我计划在支持添加较低级别的API在将来,我真的不希望摆脱actionbarcompat的现在。

Would this fix any potential issues? I'm new to Android so wouldn't know. Because the issue seems to only happen with LG devices running 4.1.2 using actionbarcompat - but because I plan to add in support for lower API levels in the future, I don't really want to get rid of actionbarcompat for now.

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");
}

谢谢!

PS:设备的问题是,LG的运行4.1.2

PS: Device in question is LG's running 4.1.2

推荐答案

显然,这是在Android中本身就是一个错误。它是固定用下面提交

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

commit 332944f8a0a001c1754ce3298edbb4246e53c8fb
Author: zobject <[email protected]>
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

这篇关于无效的有效载荷类型的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 04:35