BreakIterator.Previous在Android V2中失败?

BreakIterator.Previous在Android V2中失败?,android,Android,以下代码在Android4上运行良好,但在Android2中会导致IllegalArgumentException 有什么线索吗 Locale currentLocale = new Locale("en_UK"); final BreakIterator boundary = BreakIterator.getSentenceInstance(currentLocale); boundary.setText("a"); int thisThrowsExceptionInVersion2 =

以下代码在Android4上运行良好,但在Android2中会导致IllegalArgumentException

有什么线索吗

Locale currentLocale = new Locale("en_UK"); 
final BreakIterator boundary = BreakIterator.getSentenceInstance(currentLocale);
boundary.setText("a"); 
int thisThrowsExceptionInVersion2 = boundary.preceding(1);
例外情况:

08-08 22:29:14.414: E/AndroidRuntime(329): Caused by: java.lang.IllegalArgumentException
08-08 22:29:14.414: E/AndroidRuntime(329):  at java.text.RuleBasedBreakIterator.validateOffset(RuleBasedBreakIterator.java:74)
08-08 22:29:14.414: E/AndroidRuntime(329):  at java.text.RuleBasedBreakIterator.preceding(RuleBasedBreakIterator.java:158)
08-08 22:29:14.414: E/AndroidRuntime(329):  at kalle.palle.namespace.KallePalleActivity.onCreate(KallePalleActivity.java:26)

下面是姜饼代码中的validateOffset

private void validateOffset(int offset) {
    CharacterIterator it = wrapped.getText();
    if (offset < it.getBeginIndex() || offset >= it.getEndIndex()) {
        throw new IllegalArgumentException();
    }
}
private void validateOffset(int offset){
Characteristerator it=wrapped.getText();
if(offset=it.getEndIndex()){
抛出新的IllegalArgumentException();
}
}
在ICS中,代码如下所示

private void validateOffset(int offset) {
    CharacterIterator it = wrapped.getText();
    if (offset < it.getBeginIndex() || offset > it.getEndIndex()) {
        String message = "Valid range is [" + it.getBeginIndex() + " " + it.getEndIndex() + "]";
        throw new IllegalArgumentException(message);
    }
}
private void validateOffset(int offset){
Characteristerator it=wrapped.getText();
if(offsetit.getEndIndex()){
String message=“有效范围为[“+it.getBeginIndex()+”“+it.getEndIndex()+”];
抛出新的IllegalArgumentException(消息);
}
}
=
已更改为
。在2.X设备中,端点偏移检查似乎是错误的。在传递到前面的
的偏移量与字符串的结束索引重叠的情况下尤其如此。这似乎是框架中的错误。
可以在libcore/luni/src/main/java/java/text/RuleBasedBreakIterator.java的AOSP代码中找到源代码。

这是,这是,你是说安卓4.X和2.X,对吗?不是API级别4和2,显然我是这样假设的。我花了几分钟才明白你说的lol是什么意思。是的,Android API 10级在这方面失败了。它似乎在android-15上工作。我希望确认这是我的问题的原因,而不是代码中的一些细微错误或使用BreakIterator。