Note that there are some explanatory texts on larger screens.

plurals
  1. POpass to lists from AsyncTask to activity
    primarykey
    data
    text
    <p>i have in my activity two methods getListIDs AND getNamesIDs so in the AsycTask class there is some process in background to get from database Tow Lists , the first list Supposed to send it's result to getListIDs() and activity class , and second list also to getNamesIDS()</p> <p>My Q is : how to return those two lists from Async class two used into Two methods in activity class ?</p> <p>my code in activity class :</p> <pre><code> public List&lt;Student&gt; getListIDs() { return list; // return full list public List&lt;Student&gt; getNamesIDs() { return list; // return full list </code></pre> <p>my code in AsyncTask class :</p> <pre><code> public class Hashom extends AsyncTask&lt;Void, Void, String&gt; { static Activity mActivity; ProgressDialog progressDialog; public Hashom(Activity activity, ProgressDialog progressDialog) { super(); this.progressDialog = progressDialog; this.mActivity = activity; } final String NAMESPACE = "http://ws.sams.com"; final String URL = "http://88.198.82.92:8080/sams1/services/listActivityWS?WSDL"; localhost final String METHOD_NAME = "getCurrentClassList"; final String SOAP_ACTION = "http://ws.sams.com/getCurrentClassList"; final String NAMESPACE2 = "http://ws.sams.com"; final String URL2 = "http://88.198.82.92:8080/sams1/services/listActivityWS?WSDL"; // usint // localhost final String METHOD_NAME2 = "getStudentId"; final String SOAP_ACTION2 = "http://ws.sams.com/getStudentId"; final String NAMESPACE3 = "http://ws.sams.com"; final String URL3 = "http://88.198.82.92:8080/sams1/services/listActivityWS?WSDL"; // usint // localhost final String METHOD_NAME3 = "getCourseName"; final String SOAP_ACTION3 = "http://ws.sams.com/getCourseName"; final String NAMESPACE4 = "http://ws.sams.com"; final String URL4 = "http://88.198.82.92:8080/sams1/services/listActivityWS?WSDL"; // usint // localhost final String METHOD_NAME4 = "getClassId"; final String SOAP_ACTION4 = "http://ws.sams.com/getClassId"; List&lt;Student&gt; StudentIdList = new ArrayList&lt;Student&gt;(); List&lt;Student&gt; StudentNamesList = new ArrayList&lt;Student&gt;(); @Override protected String doInBackground(Void... voids) { SoapObject request3 = new SoapObject(NAMESPACE, METHOD_NAME); HttpTransportSE androidHttpTransport3 = new HttpTransportSE(URL); PropertyInfo pi3 = new PropertyInfo(); pi3.setName("TID"); pi3.setValue(1); pi3.setType(Integer.class); request3.addProperty(pi3); SoapSerializationEnvelope envelope3 = new SoapSerializationEnvelope( SoapEnvelope.VER11); envelope.setOutputSoapObject(request); androidHttpTransport3.call(SOAP_ACTION, envelope3); KvmSerializable result = (KvmSerializable) envelope3.bodyIn; String str = null; for (int i = 0; i &lt; result.getPropertyCount(); i++) { str = ((String) result.getProperty(i).toString()); Student hesham = new Student(str); StudentNamesList.add(hesham); } } catch (Exception e) { } // //////////////////////////////////////////////////////////////////////////////////// SoapObject request4 = new SoapObject(NAMESPACE2, METHOD_NAME2); PropertyInfo pi4 = new PropertyInfo(); pi4.setName("TID"); pi4.setValue(1); pi4.setType(Integer.class); request.addProperty(pi4); SoapSerializationEnvelope envelope4 = new SoapSerializationEnvelope( SoapEnvelope.VER11); envelope.setOutputSoapObject(request4); HttpTransportSE androidHttpTransport4 = new HttpTransportSE(URL2); try { androidHttpTransport4.call(SOAP_ACTION2, envelope4); KvmSerializable result = (KvmSerializable) envelope.bodyIn; String str = null; for (int i = 0; i &lt; result.getPropertyCount(); i++) { str = ((String) result.getProperty(i).toString()); Student hesham = new Student(str); StudentIdList.add(hesham); } } catch (Exception ex) { } return "hh"; // i want here to return two lists (StudentIdList) and StudentNamesList and calling the reult into activity class } @Override protected void onPostExecute(String result) { Intent intent = new Intent(mActivity, ListActivity1.class); mActivity.startActivity(intent); progressDialog.dismiss(); } } </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. 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