Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 仅在galaxy s6+上自定义键盘崩溃;_Java_Android_Keyboard - Fatal编程技术网

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

Java 仅在galaxy s6+上自定义键盘崩溃;,java,android,keyboard,Java,Android,Keyboard,这就是错误: java.lang.NullPointerException:尝试调用虚拟方法“void” android.view.textservice.SpellCheckerSession.getSentenceSuggestions(android.view.textservice.TextInfo[]), int)“”位于空对象引用上 com.allegretti.tastiera.free.MyKeyboard.updateCandidates(MyKeyboard.java:788

这就是错误:

java.lang.NullPointerException:尝试调用虚拟方法“void” android.view.textservice.SpellCheckerSession.getSentenceSuggestions(android.view.textservice.TextInfo[]), int)“”位于空对象引用上 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);
        }
    } }
private boolean IsEntenceSpellCheckSupported(){
返回Build.VERSION.SDK\u INT>=Build.VERSION\u CODES.JELLY\u BEAN;}
私有void updateCandidates(){
如果(!mCompletionOn){
如果(mComposing.length()>0){
如果(IsEntenceSpellCheckSupported()){
ArrayList=新建ArrayList();
//添加(mComposing.toString());
Log.d(“软键盘”,“请求:+mComposing.toString());
mScs.getSentenceSuggestions(newtextinfo[]{newtextinfo(mComposing.toString())},5);
设置建议(列表、真、真);
}否则{
getSuggestions(新文本信息(mComposing.toString()),5);
}
}否则{
设置建议(空、假、假);
}
} }

可能重复的@Simze请阅读标题,与其他问题不同,我不这样做understand@PavneetSingh在几乎所有的情况下,它都是相似的,肯定有一些对象是空的,OP正在尝试访问它。为什么只有在银河系中不起作用?可能是@Simze的副本请阅读标题,这和其他问题不一样我不知道understand@PavneetSingh在几乎所有的情况下,它都是相似的,肯定有一些物体是空的,OP正试图访问它。为什么只有在银河系中才不起作用呢?