I'm stuck on a tough architectural problem. I have a collection of web
services that produce data that will populate UI components -
TextViews, ListViews, and so on. Each web service may take up to about
10 seconds to respond, or it might not respond at all. When I click a
button in the UI that requires data from the web services I need to
show a ProgressDialog until either the data arrives or it times out.

I'm pretty sure that an IntentService is the best way to wrap the web
services. From the documents (http://developer.android.com/reference/
android/app/IntentService.html) "This "work queue processor" pattern
is commonly used to offload tasks from an application's main thread."
Also "Note that unlike other application components, calls on to the
IBinder interface returned here may not happen on the main thread of
the process."

The UI needs to get data back (asynchronously) from the IntentService,
which means using AIDL, onBind, and all that. But from the documents
(http://developer.android.com/guide/developing/tools/aidl.html) we
have "By default, IPC calls are synchronous. If you know that an IPC
service takes more than a few milliseconds to complete, you should not
call it in the Activity/View thread, because it might hang the
application (Android might display an "Application is Not Responding"
dialog). Try to call them in a separate thread."

Of course, that "separate thread" stuff in the AIDL docs in nonsense.
If you spawn a separate thread in an Activity it will get blown up in
OnDestroy. But what do they mean by "By defualt"? Are there cases
where the IPC can be asynchronous? Is that what is meant by the text
in the IntentService docs "may not happen on the main thread"? How
does this work?


-- 
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