1

This is the error:

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.textservice.SpellCheckerSession.getSentenceSuggestions(android.view.textservice.TextInfo[], int)' on a null object reference at com.allegretti.tastiera.free.MyKeyboard.updateCandidates(MyKeyboard.java:788) at com.allegretti.tastiera.free.MyKeyboard.handleCharacter(MyKeyboard.java:856) at com.allegretti.tastiera.free.MyKeyboard.onKey(MyKeyboard.java:761)

My code:

private boolean isSentenceSpellCheckSupported() {
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; } 

private void updateCandidates() {
    if (!mCompletionOn) {
        if (mComposing.length() > 0) {
            if (isSentenceSpellCheckSupported()) {

                ArrayList<String> list = new ArrayList<String>();
                //list.add(mComposing.toString());
                Log.d("SoftKeyboard", "REQUESTING: " + mComposing.toString());
                mScs.getSentenceSuggestions(new TextInfo[]{new TextInfo(mComposing.toString())}, 5);
                setSuggestions(list, true, true);
            }else{
                mScs.getSuggestions(new TextInfo(mComposing.toString()), 5);
            }
        } else {
            setSuggestions(null, false, false);
        }
    } }
Pavneet_Singh
  • 36,884
  • 5
  • 53
  • 68

0 Answers0