Snake
Snake

Reputation: 14638

Do GUI stuffs on the doInBackground

I read about asyncTask and learnt that onPostExecute and onPrExecute are used to update the UI while doInBackground is used to do heavy operation on another thread.

I was wondering, would it be "bad" to do GUI update on the DoInBackGround. For example, displaying a Toast etc.

Why I want to do that? Because sometime I want to use the results of this long operations to display things and I don't want to have private variables in my task just to store them for GUI purposes

thank you

Upvotes: 0

Views: 68

Answers (1)

Awais Tariq
Awais Tariq

Reputation: 7754

doInbackground itself means do me in background not on foreground. Thing what you are looking for can be achieved by publishProgress(). Further still if you don't want to use it then try to run another thread in doInbackground method with runOnUi support..

Upvotes: 3

Related Questions