Synchronous HTTP get?

tchart

Well-Known Member
Licensed User
Longtime User
Not sure if this is possible or not, Ive tried several methods but none seem to work.

I would like to call a sub/function which fires off an HTTP request and then synchronously gets the response which is returned to the caller from the sub/function.

Something like this;

B4X:
Dim resp as string
resp = SynchronousGet("www.google.com")

I don't want to have to rely on a call back sub as I need the call to happen "in line" with what I'm doing.

Ive tried using a class module with a wait/sleep function but the call back from the httpclient only gets fired once my wait/sleep loop times out (I'd imagine it'd loop forever if I didnt have a time out)

Is this even possible under Android or should I rethink my approach?

Thanks
 
Top