NullPointerException Error on SuggestionSpan Website

I get a NullPointerException on the SuggestionSpan site. (A stack trace is included below). Since the stack trace does not include any of my code, I absolutely do not know where to start debugging.

An error can be reproduced whenever I press the spacebar (or select a word) when using EditText. I tried several keyboards, including Android Android, but the same error appears.

FATAL EXCEPTION: main java.lang.NullPointerException at android.text.style.SuggestionSpan.<init>(SuggestionSpan.java:128) at android.text.style.SuggestionSpan.<init>(SuggestionSpan.java:101) at android.widget.SpellChecker.createMisspelledSuggestionSpan(SpellChecker.java:392) at android.widget.SpellChecker.onGetSuggestions(SpellChecker.java:300) at android.view.textservice.SpellCheckerSession.handleOnGetSuggestionsMultiple(SpellCheckerSession.java:198) at android.view.textservice.SpellCheckerSession.access$000(SpellCheckerSession.java:86) at android.view.textservice.SpellCheckerSession$1.handleMessage(SpellCheckerSession.java:112) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4424) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) 

EDIT: I can only reproduce the error on my Nexus S with 4.0.3, but not on emulators with other OS versions. Weird

EDIT 2: A strange thing! I just dragged EditText into another action, and the same thing happens. Not a single code is attached to it, nor any XML changes made to it.

+1
android
source share
1 answer

After days of research, it turns out that getResources (). getConfiguration (). locale is null. I'm not sure if this is a problem specific to some versions of Android / some devices (my Nexus S works 4.0.3).

But I worked on this issue by checking the Activity constructor (since the context provided for SuggestionSpan is my activity), whether locale is null, and then sets the default value, if any.

  // to prevent a weird bug where locale is null Configuration config = getResources().getConfiguration(); if (config.locale == null) config.locale = Locale.getDefault(); 

What I've done. I am absolutely sure that this is not the best way. Does anyone have any idea?

+4
source share

All Articles