自定义键盘仅在galaxy s6 +上崩溃

时间:2016-10-21 14:02:46

标签: java android keyboard

这是错误:

  

java.lang.NullPointerException:尝试调用虚方法'void   android.view.textservice.SpellCheckerSession.getSentenceSuggestions(android.view.textservice.TextInfo [],   int)'在null对象引用处   com.allegretti.tastiera.free.MyKeyboard.updateCandidates(MyKeyboard.java:788)     在   com.allegretti.tastiera.free.MyKeyboard.handleCharacter(MyKeyboard.java:856)     在com.allegretti.tastiera.free.MyKeyboard.onKey(MyKeyboard.java:761)

我的代码:

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

0 个答案:

没有答案