有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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

这就是错误:

java.lang.NullPointerException: Attempt to invoke virtual method 'void 安卓.view.textservice.SpellCheckerSession.getSentenceSuggestions(安卓.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)

我的代码:

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) 个答案