Java.lang.IndexOutOfBoundsException: getChars (7 ... 0) has an end before running

My users send me unhandled exceptions through http://code.google.com/p/android-remote-stacktrace/

I get the following, but have no idea what that means.

java.lang.IndexOutOfBoundsException: getChars (7 ... 0) has end before start
   at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:935)
   at android.text.SpannableStringBuilder.getChars(SpannableStringBuilder.java:847)
   at android.text.TextUtils.getChars(TextUtils.java:69)
   at android.text.SpannableStringBuilder.<init>(SpannableStringBuilder.java:59)
   at android.text.SpannableStringBuilder.subSequence(SpannableStringBuilder.java:839)
   at android.widget.TextView.extractTextInternal(TextView.java:4541)
   at android.widget.TextView.reportExtractedText(TextView.java:4580)
   at android.widget.TextView.finishBatchEdit(TextView.java:4723)
   at android.widget.TextView.endBatchEdit(TextView.java:4705)
   at com.android.internal.widget.EditableInputConnection.endBatchEdit(EditableInputConnection.java:54)
   at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:586)
   at android.view.inputmethod.BaseInputConnection.commitText(BaseInputConnection.java:174)
   at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:120)
   at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:231)
   at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:57)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:123)
   at android.app.ActivityThread.main(ActivityThread.java:4338)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:521)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
   at dalvik.system.NativeStart.main(Native Method)
+3
source share
4 answers

This is a known bug in the Android platform. Here is a link to the problem .

+3
source

if android cannot set the choice you are using using the cursor position ... I solved the problem by setting it exactly to the line crash

editor.setSelection(editor.getText().length(), editor.getText().length());
+1
source

For those who are still struggling with this problem, placing the following code in your activity onResumewill solve it:

textEntry.setSelection(textEntry.getText().length(), textEntry.getText().length());
0
source

I fixed it with customEntry. Changed onSelectionChanged and put the code from loopj there!

My code is:

@Override
protected void onSelectionChanged(int selStart, int selEnd) {
    if (selStart >= 0) {
        super.onSelectionChanged(selStart, selEnd);
    } else {
        setSelection(getText().length());
    }
}
0
source

Source: https://habr.com/ru/post/1731693/


All Articles