png
png

Reputation: 4408

Showing a message from an async task

I am doing data fetch from net in an external task. Now this fetch happens in two steps. So I want to display some message after the first step.

This will happen in the async task not on the UI task. On the main UI task I already have a progress bar in the preexecute method. I would like to know if there is a way to display something from the background async task.

I saw handle to be used for threads. Do we have something similar for async task?

Upvotes: 1

Views: 308

Answers (2)

Thommy
Thommy

Reputation: 5407

You have to Override the onProgressUpate Method of your AsyncTask. There you can do the stuff to Display the Text. To trigger onProgressUpdate you have to call publishProgress() in your doInBackground-Method.

Upvotes: 1

claesv
claesv

Reputation: 2113

AsyncTask has an onProgressUpdate method which runs on the UI thread. Couldn't you use that somehow?

Upvotes: 2

Related Questions