Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does android handle GUI events?

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)?

enter image description here

like image 942
Mike G Avatar asked Nov 21 '11 15:11

Mike G


People also ask

How do we handle events in Android?

You will use onKey() event handler to handle such event. This is called when the user presses the key, releases the key, or any movement gesture on the screen. You will use onTouch() event handler to handle such event. This is called when the user selects a menu item.

Does Android use GUI?

Android applications use classes in the Java language to implement various aspects of Graphical User Interface (GUI) functionality. Developers can make use of these classes to create standard behavior within their apps. As well as Java class files, Android applications use XML data to declare screen layouts.

What are event listeners in Android?

Event listeners. An event listener is an interface in the View class that contains a single callback method. These methods will be called by the Android framework when the View to which the listener has been registered is triggered by user interaction with the item in the UI.


1 Answers

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

I don't know what you think the "OS looper" is. The Looper runs in your process, if that's what you mean.

Where does ViewRootImpl(handler).dispatchMessage(Message) reside? Application or OS?

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.

Can I intercept GUI generated events in the main looper ?

Only by modifying the firmware to replace various classes like ViewRootImpl with your own code.

Can we safely assume that all GUI generated events are handled in ViewRootImpl(handler).handleCallback(Message)?

I certainly would not make that assumption. For example, not all applications use the widget framework (e.g., games).

like image 151
CommonsWare Avatar answered Oct 20 '22 03:10

CommonsWare