gpt4 book ai didi

android - 在安卓 P : Dropping event due to no window focus: KeyEvent

转载 作者:行者123 更新时间:2023-11-29 02:22:15 50 4
gpt4 key购买 nike

Android P 中,启动时应用程序无法按预期工作并抛出警告:

 W/ViewRootImpl: 
Dropping event due to no window focus: MotionEvent { action=ACTION_DOWN, KeyCode = DPAD_DOWN}

W/ViewRootImpl: Cancelling event due to no window focus: MotionEvent { action=ACTION_UP, KeyCode = DPAD_DOWN} and its not allowing any action to performed.

检查图像以获取详细警告。

注意:同一应用程序在 Android O 中运行良好,但在 Android P 中,有时 PopupMenu 中缺少焦点 项目并且在重新启动系统之前不会重新获得焦点。使用后 dispatchKeyEvent 并将 View 动态设置为 v.requestFocus(); 应用程序开始运行得稍微好一些,但有时仍会观察到警告,感觉系统对用户来说已挂起.查看下面的代码 fragment 了解详情:

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
LogUtils.d(TAG, String.valueOf(event.getKeyCode()));
this.getWindow().getDecorView().setFocusable(true);
return super.dispatchKeyEvent(event);
}

我的问题是,如何将丢失的焦点动态设置到 PopupMenuRecyclerView 或者如何在 Android 中运行的应用程序中克服这个问题

请提出建议,我在 stackOverflow 中遇到了相同类型的问题,但没有合适的解决方案,因此发布问题并等待所有类型的建议和答案。提前致谢。 enter image description here

最佳答案

在我的例子中,类似的问题是由在任何地方使用 onKeyDown() 和 KeyEvent.ACTION_DOWN 引起的,包括在按键时显示对话框时。使用 onKeyUp() 和 KeyEvent.ACTION_UP 显示对话框和 Activity 为我解决了这个问题。

关于android - 在安卓 P : Dropping event due to no window focus: KeyEvent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54702989/

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