Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>AsyncTask API: <a href="http://developer.android.com/reference/android/os/AsyncTask.html" rel="noreferrer">http://developer.android.com/reference/android/os/AsyncTask.html</a></p> <p>After reading the documentation above, it's clear that AsyncTask should work fine in version 2.3.3 (it was added in API 3 = Android 1.5).</p> <p>Are you sure the correct params are being passed? Here is a simple example of an Async Task which calls a WebService and shows the result in a TextView of the activity, I hope this helps you get in the right track:</p> <pre><code>private class AsyncTaskWebServiceCaller extends AsyncTask&lt;Void, Void, String&gt; { private ProgressDialog dialog = new ProgressDialog(MainActivity.this); @Override protected void onPreExecute() { dialog.setMessage("Connecting to Web Service..."); dialog.show(); } @Override protected String doInBackground(Void...voids) { //create the envelope for the message SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = false; //get the card (SOAPObject) that will be put into the envelope SoapObject soapObject = new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME); envelope.setOutputSoapObject(soapObject); //put something on the card PropertyInfo propertyInfo = new PropertyInfo(); propertyInfo.setType(PropertyInfo.STRING_CLASS); propertyInfo.setName("macAddress"); propertyInfo.setValue(macAddress); soapObject.addProperty(propertyInfo); //call WebService try { HttpTransportSE httpTransportSE = new HttpTransportSE(SOAP_ADDRESS); httpTransportSE.debug = true; httpTransportSE.call(SOAP_ACTION, envelope); Object response = envelope.getResponse(); return response.toString(); } catch (Exception e) { String text = "Oops!! App has crashed with exception: "+e.getMessage() + "\n" + "Stack trace below:\n"; StackTraceElement[] stackTrace = e.getStackTrace(); for (StackTraceElement stackTraceElement : stackTrace) { text += stackTraceElement.toString() + "\n"; } return text; } } @Override protected void onPostExecute(String result) { if (dialog.isShowing()) { dialog.dismiss(); } TextView textView = (TextView)findViewById(R.id.textView1); textView.setText(result); } } </code></pre> <p>And to call the AsyncTask, just do this:</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); new AsyncTaskWebServiceCaller().execute(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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