29.03.2011 0:21, john brown пишет:
Kostya,

Part of my problem is that I do not know enough to understand the
documentation. In this specific documentation I got lost when it said:
          publishProgress(...
          setProgressPercent(....
          showDialog(.....

AsyncTask is pretty simple. It has two sides: the worker thread and the UI thread.

Your code that performs a lengthy operation on the worker thread can call publishProgress(), which is automatically dispatched to the UI thread and turned into onProgressUpdate().

This is needed because Android UI components can only be used from the UI thread, and AsyncTask's doInBackground() runs on a worker thread (which is AsyncTask's reason for existence).

UI thread is defined here:

http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html#Threads

which also gives some simple rules to follow when dealing with threads on Android.

Back to your error message. What it means (in translation from Androidese) is that your code tries to create a UI component (ProgressDialog) from the worker thread. This violates the rule that you can only touch the UI from the UI thread.


I do not know what those lines mean. I type them in my code, they are
not recognized and produce errors in my editor. (eclipse)

Yes, you really need to know at least the basics of Java to program with it.

-- Kostya

(I am studying. I have ordered new books. etc)

Thanks, John Brown

--
Kostya Vasilyev -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to