Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>How do you declare your AsyncTask class ?<br /></p> <p>According to the <a href="http://developer.android.com/reference/android/os/AsyncTask.html" rel="nofollow">AsyncTask documentation</a> </p> <blockquote> <p>The three types used by an asynchronous task are the following:</p> <p>Params, the type of the parameters sent to the task upon execution. Progress, the type of the progress units published during the background computation. Result, the type of the result of the background computation. Not all types are always used by an asynchronous task. To mark a type as unused, simply use the type Void.</p> </blockquote> <p>It should be something like :</p> <pre><code>private class MyAsyncTask extends AsyncTask&lt;Param, Progress, Result&gt; </code></pre> <p>This will define <code>doInBackground()</code> signature as follow :</p> <pre><code>protected Result doInBackground(Param... params) </code></pre> <p>You can then return the result at the end of <code>doInBackground()</code> instead of <code>null</code>.</p> <p><strong>Edit :</strong></p> <p>Applied to you example, it should look to something like this :</p> <pre><code>public class MyAsyncTask extends AsyncTask&lt;Void, int[], String&gt; { protected Void doInBackground(Void... args) { request = new SoapObject(NAMESPACE, METHOD_NAME); username = new PropertyInfo(); username.setName("UserName"); username.setValue(Username); username.setType(String.class); request.addProperty(username); password = new PropertyInfo(); password.setName("Password"); password.setValue(Password); password.setType(String.class); request.addProperty(password); SoapSerializationEnvelope envp = new SoapSerializationEnvelope( SoapEnvelope.VER11); envp.dotNet = true; envp.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); try { androidHttpTransport.call(SOAP_ACTION, envp); SoapPrimitive response = (SoapPrimitive) envp.getResponse(); // return your result here return response.toString(); } catch (Exception e) { e.printStackTrace(); } // return null if something went wrong return null; } @Override protected void onPostExecute(String result) { if (dialog != null) { dialog.dismiss(); dialog = null; } if (result == null) { // handle null here, for example : // result = "Fail"; } // use "Fail".equals(result) instead of result.equals("Fail") // to avoid error if result is null if ("Fail".equals(result)) { etPassword.setText(""); textValidation.setText("UserName Or Password is Wrong."); } else { etUsername.setText(""); etPassword.setText(""); } } } </code></pre>
    singulars
    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. This table or related slice is empty.
    1. This table or related slice is empty.
    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