Ellen Spertus
Ellen Spertus

Reputation: 6815

Does Android enforce performing UI actions only from the UI thread?

I understand that Android applications have a single UI thread.

Does the runtime enforce that all UI calls are made from this thread, or is it up to the programmer to make sure no UI calls are made from other threads?

Upvotes: 0

Views: 207

Answers (3)

Macarse
Macarse

Reputation: 93173

You need to do every operation with UI widgets in the UI thread. To do so you can use different approaches. I will list a few articles for you to read:

Upvotes: 0

Veeresh
Veeresh

Reputation: 1052

You cannot operate on UI items when not on UI thread. For example, you cannot change the text of a textView from a non-UI thread. You are responsible to make sure you are on UI thread when working with UI items.

Upvotes: 0

JAL
JAL

Reputation: 3319

If you try to touch a view from another thread other than the owning UI thread you will get a nice CalledFromWrongThreadException.

JAL

Upvotes: 5

Related Questions