How does android handle GUI events?

I am trying to understand what happens when a button is pressed in android. So I set a couple of breakpoints for a simple click. The figure shows what happens when a button is clicked on my questions: (the events generated by the GUI are events that are generated as a result of interaction with gui, for example, pressing buttons, editing text, etc.)

1- Is Looper.loop () the main loop for an application or OS looper?

2 Where is ViewRootImpl (handler) .dispatchMessage (Message) located? Application or OS?

3- Can I intercept events generated by the graphical interface in the main looper? if so, how?

4 Can we safely assume that all user-generated graphic events are processed in ViewRootImpl (handler) .handleCallback (Message)?

enter image description here

+6
source share
1 answer

Is Looper.loop () the main loop for an application or OS looper?

I do not know what you think of the "OS looper". Looper works in your process if that is what you mean.

Where is ViewRootImpl (handler) .dispatchMessage (Message) located? Application or OS?

I do not know what you think of the "OS" in this context. ViewRootImpl is a class compiled by Dalvik that loads into your Dalvik VM, and its code is executed in your process. Otherwise, you cannot see it in the stack trace.

Can I intercept the generated GUI events in the main looper?

Only by changing the firmware to replace various classes, such as ViewRootImpl , with native code.

Is it safe to assume that all events created by a graphic event are processed in ViewRootImpl (handler) .handleCallback (Message)?

Of course, I would not have made this assumption. For example, not all applications use the widget framework (for example, games).

+2
source

Source: https://habr.com/ru/post/902016/


All Articles