diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 00cd74b19..b467a32a2 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1875,14 +1875,16 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return; } - final boolean selectedATypedWordAndItsInUserUnigramDic = - !selectedANotTypedWord && mUserUnigramDictionary.isValidWord(suggestion); - final boolean isValidWord = AutoCorrection.isValidWord( - mSuggest.getUnigramDictionaries(), suggestion, true); - final boolean needsToAddToUserUnigramDictionary = selectedATypedWordAndItsInUserUnigramDic - || !isValidWord; - if (needsToAddToUserUnigramDictionary) { - mUserUnigramDictionary.addWord(suggestion.toString(), frequencyDelta); + if (null != mSuggest && null != mUserUnigramDictionary) { + final boolean selectedATypedWordAndItsInUserUnigramDic = + !selectedANotTypedWord && mUserUnigramDictionary.isValidWord(suggestion); + final boolean isValidWord = AutoCorrection.isValidWord( + mSuggest.getUnigramDictionaries(), suggestion, true); + final boolean needsToAddToUserUnigramDictionary = + selectedATypedWordAndItsInUserUnigramDic || !isValidWord; + if (needsToAddToUserUnigramDictionary) { + mUserUnigramDictionary.addWord(suggestion.toString(), frequencyDelta); + } } if (mUserBigramDictionary != null) {