I’m new to Java, but have been a .NET developer for years now and I am a bit confused about the point of the RequestListener object as I can’t retrieve the results of my asynchronous calls on the UI thread from what I can tell. My research has told me I should not use singletons or the application context object for getting and storing data. I could use sqlLite, but the data I need is too transient to bother. I would like to know how to have the asyncfacebookrunner object report back it’s responses to the UI thread so I can proceed to make decisions between my own api and the objects returned to me from the facebook calls I am making in the async calls.
Am I missing something? I can’t seem to find a way to get data out. I can pass a Bundle in, but I’m not too sure how to get data out. I would think I would pass it an Intent object to retrieve, but I am not seeing it. I think my eyes are crossed from lack of sleep at this point. Any help here?
The AsyncFacebookRunner automatically makes the request in a separate thread, and then, posts back to the UI thread in the RequestListener methods, i.e.
That’s the beauty of AsyncTasks. Refer to the Android docs on AsyncTasks.
http://developer.android.com/reference/android/os/AsyncTask.html
doInBackground performs operations in a seperate thread.
onPostExecute posts back to the UI thread.
AsyncTask’s are built using Thread’s and Handler’s. Thread’s are seperate from the UI thread, and Handler’s post back into the UI Thread, also known as the Main Looper.