Samsung Galaxy Android 上的建议弹出窗口 window 出现空指针异常 Android 7

Null pointer exception in suggestions popup window on Samsung Galaxy Android 7

我发现我的应用程序经常发生异常崩溃,但仅限于三星 Galaxy 设备 运行 Android 7. 由于堆栈跟踪中没有我的应用程序代码,我我发现除了出去购买这些昂贵的设备之一之外,很难找到它。这里有什么线索可以追踪吗?

这似乎是与输入控件关联的建议弹出窗口中发生的内部错误,大概是我应用程序主屏幕上的 EditTextEditText 不应该提出建议,因为我也在使用

searchBox.setImeOptions(EditorInfo.IME_ACTION_SEARCH | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
        searchBox.setInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

堆栈跟踪如下:

java.lang.NullPointerException: 
    at android.widget.Editor$SuggestionsPopupWindow.initContentView(Editor.java:3729)
    at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:3390)
    at android.widget.Editor$SuggestionsPopupWindow.<init>(Editor.java:3675)
    at android.widget.Editor.replace(Editor.java:431)
    at android.widget.Editor.run(Editor.java:2354)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6776)
    at java.lang.reflect.Method.invoke(Native Method:0)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

这似乎是三星设备中的一个错误。 看这里: http://developer.samsung.com/forum/thread/android-app-crash-because-of-null-pointer-exception-on-setting-onclick-listener-in-editor-class/201/309993?boardName=SDK&startId=zzzzz~

三星 Android 系统可能存在错误。 对于这种平台的bug我相信,我想用try{}catch{}来处理它们,那么应用程序至少应该可以维持。 当然,如果异常发生在你的应用程序启动过程中,那么用 try{} catch... 是不可能处理的,最好找到根本原因并找到真正的解决方案来修复或解决它。但是如果异常发生在你的应用程序功能中,你捕获这个异常后很容易找到一种方法来处理它,那么你的应用程序就不会崩溃。 我喜欢用"try...catch"来处理这种突发情况

如果您的视图正在扩展 Activity,请尝试扩展 AppCompatActivty,希望它能解决您的问题。