android如何处理GUI事件?
我试图了解在 android 中单击按钮时会发生什么。因此,我为简单的按钮单击设置了几个断点。图片显示了单击按钮时会发生什么我的问题是:(GUI 生成的事件是由于与 gui 交互而生成的事件,例如按钮单击、编辑文本等...)
1- Looper.loop() 是应用程序的主循环还是操作系统循环?
2- ViewRootImpl(handler).dispatchMessage(Message) 驻留在哪里?应用程序还是操作系统?
3-我可以在主循环中拦截 GUI 生成的事件吗?如果是的话怎么办?
4-我们可以安全地假设所有 GUI 生成的事件都在 ViewRootImpl(handler).handleCallback(Message) 中处理吗?
I’m trying to understand what happens when a button is clicked in android. So I set up a couple of break points for a simple button click. The picture shows what happens when a button is clicked my questions are: (GUI generated events are events that are generated as a result of interaction with the gui for example Button Clicks, editing text etc…)
1- Is Looper.loop() the main loop for the application or the OS looper ?
2- Where does ViewRootImpl(handler).dispatchMessage(Message) reside? Application or OS?
3- Can I intercept GUI generated events in the main looper ? if yes then how?
4- Can we safely assume that all GUI generated events are handled in ViewRootImpl(handler).handleCallback(Message)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道你认为“操作系统循环程序”是什么。
Looper
在您的进程中运行,如果这就是您的意思。我不知道您认为“操作系统”在这种情况下是什么。
ViewRootImpl
是一个 Dalvik 编译的类,它被加载到您的 Dalvik VM 中,并且其代码在您的进程中执行。否则,您将无法在堆栈跟踪中看到它。只能通过修改固件,将
ViewRootImpl
等各种类替换为自己的代码。我当然不会做出这样的假设。例如,并非所有应用程序都使用小部件框架(例如游戏)。
I don't know what you think the "OS looper" is. The
Looper
runs in your process, if that's what you mean.I don't know what you think the "OS" is in this context.
ViewRootImpl
is a Dalvik-compiled class that is loaded into your Dalvik VM and its code executes within your process. Otherwise, you would not be able to see it in your stack trace.Only by modifying the firmware to replace various classes like
ViewRootImpl
with your own code.I certainly would not make that assumption. For example, not all applications use the widget framework (e.g., games).