Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Why not create a Constructor for the Login class, like below? In my case, I'm passing an Activity to my AsyncTask so that I can call a callback function when done, but in your case, you could also pass an Array of your Strings.</p> <p>In this case below, the args array is passed to the class constructor while the params array is passed to the doInBackground function. The MainActivity is passed to the AsyncTask so that the taskDone callback can be called in MainActivity once the task completes.</p> <pre><code>public class Login extends AsyncTask&lt;String, Void, String&gt; { private MainActivity activity; //These private strings are only needed if you require them //outside of the doInBackground function.... //If not, just use the params argument of doInBackground by itself private String METHODNAME, private String NAMESPACE; private String SOAPACTION; private String USER_NAME; private String USER_PASS; public Login(String[] args, MainActivity activity) { this.NAMESPACE= args[0]; this.METHODNAME = args[1]; this.SOAPACTION = args[2]; this.USER_NAME = args[3]; this.USER_PASS= args[4]; this.activity = activity; } @Override protected Void doInBackground(String... params) { //Again, use either params local to this function //or args local to the entire function... //both would be redundant String _NAMESPACE = params[0]; String _METHODNAME = params[1]; String _SOAPACTION = params[2]; String _USER_NAME = params[3]; String _USER_PASS= params[4]; //Do background stuff } protected void onPostExecute() { //dismiss progress dialog if needed //Callback function in MainActivity to indicate task is done activity.taskDone("some string"); } } </code></pre> <p>MainActivity.java</p> <pre><code>private String[] args= {"mynamespace", "mymethods", "mysoap", "myuser", "mypass"}; //to pass to constructor private String[] params= {"mynamespace", "mymethods", "mysoap", "myuser", "mypass"}; //to pass to doInBackground //Pass your args array and the current activity to the AsyncTask new Login(args, MainActivity.this).execute(params); //Callback for AsyncTask to call when its completed public void taskDone(String returnVal) { //Do stuff once data has been loaded returnText = returnVal; } </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. 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