Well,I've had some success with this, but I must be doing something wrong as I am not getting the result I am expecting.
My doInBackground returns a Boolean, and according to debug at the return command, my Boolean variable is showing as false, which is what I would expect based upon my logic. Am I right in thinking that the return from doInBackground gets passed to onPostExecute? If so then I'd expect my input parameter (which is Boolean) to be false too, but it's not, it's showing as true.
I'm just not getting that. A bit more information: private class initialiseServer extends AsyncTask<Void, Integer, Boolean>protected Boolean doInBackground(Void...voids) [Inside this code I have a Boolean variable that is initialized to false and this variable is returned.]
protected void onPostExecute(Boolean result) Would appreciate any help on this. ------------------------------------------------------------------------ David Williams Check out our WebOS mobile phone app for the Palm Pre and Pixi:<http://www.dtw-consulting.com/GolfCaddie> Golf Caddie <http://www.dtw-consulting.com/GolfCaddie> | Golf Caddie Forum <http://www.dtw-consulting.com/GolfCaddie/forum> | Golf Caddie FAQ <http://www.dtw-consulting.com/GolfCaddie/faq.html> by DTW-Consulting, Inc.
On 3/11/2011 4:00 PM, Kostya Vasilyev wrote:
12.03.2011 0:31, David Williams пишет:Does Java do certain things asynchronously then? I was thinking that things were done in a serial fashion but perhaps that is not the case.ProgressDialog.show is asynchronous, just like may other UI operations.Normally, this works, because the Android UI toolkit, just like many others (and not just for Java) is built around the "event loop" or "message loop" concept. The main thread runs in an infinite loop for processing messages, one at a time. Each message is a small task: this can include, for example, showing a dialog, redrawing a view, calling one of the application's callback methods.Your code: - Called by Android in onCreate - Calls setContentView - Calls ProgressDialog.show - Fetches stuff from the Internet - Returns from onCreateAll of the above happens on the UI thread, which waits for your onCreate to return before proceeding to the next message (== "small task").What your code in onCreate should do: - Call setContentView - Call ProgressDialog.show - Start an asynchronous operation to fetch stuff from the Internet - Return from onCreate- [ Android processes queued-up operations: draws your activity, shows the dialog ]The asynchronous fetch then should: - Run on its own thread;- When done, "tell" the application to hide the progress dialog and proceed.Hopefully, it starts to make more sense as you read through the links I've provided.This is probably the easiest way to implement asynchronous operations: http://developer.android.com/reference/android/os/AsyncTask.html -- 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/android-developers?hl=en
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
<<inline: GClogo.png>>