HTTP async problem

bluedude

Well-Known Member
Licensed User
Longtime User
Hi,

I think overall http async is great but in some cases it sucks. The main reason is the fact that you need to handle your code in a different sub (ResponseSuccess).

I have a scenario where I struggle with this. I have a list and when I click on an item in the list it needs to get detailed information through a webservice.

If that is done it needs to give me back all information so that I can handle it and open a different layout with that information.

The list click has a select case on determining a list item type, based on that type I need to do different kind of stuff. Now, because calling HTTP does not bring me back to my original part of the code I cannot use "select case" after the proces is finished. Sure, I could save stuff in a global but I don't want that, it gets messy.

Any suggestions? Can I call a HTTP and get back the results in the sub where I called the HTTP from?

Cheers,
 

agraham

Expert
Licensed User
Longtime User
This is actually the way that Android applications need to be written. Android doesn't itself support modality like Windows does, the modal dialogs mechanism is implemented in Basic4android itself. Without modality available Java applications needs to deal with dialog results in separate Subs to that which invoked the dialog.

In addition Android doesn't like you doing long long-lasting operations on the main thread and will close the application, or at least give the "Force Close" dialog, if you do. In order to avoid this your app needs to return from any Subs to run the process message loop so Android know it is alive.

I'm afraid you just need to structure your application accordingly.

EDIT:- Erel got in first while I was writing this!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…