• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

What's the "processLoop" equivalent in Android SDK?

mavavilj

Lurker
I'm using Android Studio 3 and this is my first time developing an Android app.

I've been wondering, what's the "processLoop" equivalent in Android SDK?

That is, what gets called "constantly" so that the screen updates? Is it even visible or inheritable?

I know that onCreate() is called when the program starts, but I don't know, whether there's something after this that I could use for performing UI changes any time I wish?
 
The processLoop idea that you refer to, is provided by a main thread within your application. This handles all event dispatching and application lifecycle method calls. You'll notice that no app has a main() method. This is because your app's main thread is actually created by the underlying Android framework, and defined methods are called at certain points within the application's life. There's a nice diagram somewhere which shows the state changes an app goes through during its execution.
Most things that appear in your UI are event driven. In terms of performing UI changes, that is all dictated by the components (Views) you've included in your UI design, and will react to user actions. For instance, a button will register a click handler method.
The golden rule really, is that you shouldn't put any long running method call on the main UI thread. A prime example is any network operation. Network blocking will effectively then hold up your entire application, and no UI events will be processed.
 
Most things that appear in your UI are event driven. In terms of performing UI changes, that is all dictated by the components (Views) you've included in your UI design, and will react to user actions. For instance, a button will register a click handler method.

Okay, I see. So as is usual in GUI programming, one creates and attaches listeners and they will work "invisibly" (and the corresponding "handle event" method will get called), while the program runs.
 
Yes exactly. Classic event notification system, with event handlers. You don't worry about the event dispatching, you just write the code to do something when the event happens.
 
Back
Top Bottom