Reputation: 628
I'm looking to implement a CRUD application on Android 2.3.3 as a learning PoC using SQLite database. For now, I've put in a search activity containing the search form, and a search results activity(under construction). I'm using an AsyncTask to process the db access, and want to display this data on the next activity.
Currently, I'm launching the results activity from the onPostExecute
method, and the results seem to be showing fine, but doesn't this launch the new activity in the second thread(created for AsyncTask)?
If that is the case, how do I return data back to the UI thread, and launch the results activity from there?
Please feel free to ask for clarification, I'm not a frequent poster, so my posts tend to be a little half-baked, at times.
Debojit
Upvotes: 0
Views: 276
Reputation: 14633
Only doInBackground is in the background thread. onPostExecute is in the UI thread. That's the beauty of AsyncTask: set it up in the UI thread, it does the high-latency work, such as file and network access, in the background thread, and then it responds back in the UI thread with onPostExecute.
Upvotes: 2