Note that there are some explanatory texts on larger screens.

plurals
  1. POShow 'please wait' during web service call
    text
    copied!<p>I have an activity which checks username availability via .net web services, I need to show a 'please wait' message during the call as it can take a second or two - I have experimented with AsyncTask and Threading but the problem I have is I actually want to block the main (and only) thread until the web service call has completed as I am depending on the result from it to process other logic.</p> <p>I have tried allsorts but no joy - can anyone help please?</p> <p>As requested, here is a section of my code :</p> <pre><code>private OnClickListener RegistrationListener = new OnClickListener() { public void onClick(View v) { ClearFieldHighlighting(); if (ValidateData()) { if (IsOnline()) { if (UsernameIsAvailable()) { try { iNETUserID = CreateOnlineUser(); } catch (Exception e) { } </code></pre> <p>..more code.. }</p> <p>Here is the 'UsernameIsAvailable' function :</p> <p>public boolean UsernameIsAvailable() {</p> <pre><code> Boolean bUsernameIsAvailable = false; SoapObject request = new SoapObject(TA.sNAMESPACE, TA.METHOD_IsUsernameAvailable); request.addProperty("sUsername", sEmail); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE( TA.WEBSERVICES_URL); try { androidHttpTransport.call(TA.SOAP_ACTION_IsUsernameAvailable, envelope); SoapObject thisresponse = (SoapObject) envelope.bodyIn; for (int i = 0; i &lt; thisresponse.getPropertyCount(); i++) { Object obj = thisresponse.getProperty(i); SoapPrimitive soapPrimitive = (SoapPrimitive) obj; bUsernameIsAvailable = Boolean.parseBoolean(soapPrimitive .toString()); } } catch (Exception e) { } return bUsernameIsAvailable; } </code></pre> <p>I am using KSoap2 which is an external jar file to handle the web service stuff</p> <p>Thanks Mike</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload