vincentzhou
vincentzhou

Reputation: 720

What is running on UI thread?

When all the drawing and other tasks have been finished, what code is running on the main thread? After the loading is finished, the application actually has nothing else to handle. But it could not be really idle otherwise it cannot deal with touch event. I think there should be a loop checking for user iteration, but I fail to find related information.
Thanks.

Upvotes: 0

Views: 63

Answers (2)

ThaiPD
ThaiPD

Reputation: 3741

As far as I know that :

  • In basically to say that AndroidOS always listen the User's interaction and then pass it to the active application.
  • Example when your application is running and on the top of the application stack (that mean current active application), when have some interact from User, AndroidOS will receive and ask you application first that do you want to handle this action? (with what's the action and coordinate x = ?, y = ?). If you application answer that ok, it's mine, let me handle it - that mean your application has been implement to handle that action (it's the listener for touch events (click, drag, swipe...)) and then your application will take care the rest. Other wise if your App said that NO, it's not my part, AndroidOS will continue to ask other app in the stack until there is an App say Yes. Finally if no app say YES, AndroidOS will determine to handle it by OS or Ignore.
  • So, To answer your question:

what code is running on the main thread? --> NO CODE (nothing)

The Second part

After the loading is finished, the application actually has nothing else to handle. But it could not be really idle otherwise it cannot deal with touch event. I think there should be a loop checking for user iteration when all the things had been loaded --> Application will not do anything, just loop handling from AndroidOS working and then if there is an interact action, AndroidOS will notify for application

Upvotes: 1

Pitty
Pitty

Reputation: 1977

If you are working on apart from main thread then if you want to perform any action in main thread you should write

runOnUiThread

Upvotes: 0

Related Questions