gpt4 book ai didi

android - 不支持的操作异常 : Tried to obtain display from a Context not associated with one

转载 作者:行者123 更新时间:2023-12-04 11:36:49 31 4
gpt4 key购买 nike

我在实时应用程序上遇到 UnsupportedOperationException 崩溃。所有崩溃都与 Moto Android 11 设备相关。可以看出它与onKeyUp有某种关系。但仍然不知道如何重现或解决此问题。
任何帮助,将不胜感激。

Fatal Exception: java.lang.UnsupportedOperationException: Tried to obtain display from a Context not associated with  one. Only visual Contexts (such as Activity or one created with Context#createWindowContext) or ones created with Context#createDisplayContext are associated with displays. Other types of Contexts are typically related to background entities and may return an arbitrary display.
at android.app.ContextImpl.getDisplay(ContextImpl.java:2580)
at android.content.ContextWrapper.getDisplay(ContextWrapper.java:1030)
at android.content.ContextWrapper.getDisplay(ContextWrapper.java:1030)
at android.app.Activity.onKeyUp(Activity.java:3859)
at android.view.KeyEvent.dispatch(KeyEvent.java:2866)
at android.app.Activity.dispatchKeyEvent(Activity.java:4176)
at androidx.core.app.ComponentActivity.superDispatchKeyEvent(ComponentActivity.java:122)
at androidx.core.view.KeyEventDispatcher.dispatchKeyEvent(KeyEventDispatcher.java:84)
at androidx.core.app.ComponentActivity.dispatchKeyEvent(ComponentActivity.java:140)
at androidx.appcompat.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:558)
at androidx.appcompat.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:59)
at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.dispatchKeyEvent(AppCompatDelegateImpl.java:2814)
at androidx.appcompat.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:59)
at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:418)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:6101)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5969)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5464)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5521)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5487)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5639)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5495)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5696)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5468)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5521)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5487)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5495)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5468)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:8313)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:8229)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:8190)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:5219)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:250)
at android.app.ActivityThread.main(ActivityThread.java:7766)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)

最佳答案

看看这里https://stackoverflow.com/a/72956427/3383638
所以我可以看到你可以在你的 Activity 中覆盖 onKeyUp 方法并且不返回 super.onKeyUp(...)调用。

关于android - 不支持的操作异常 : Tried to obtain display from a Context not associated with one,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67758187/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com