I am Calling a Asynctask
from Mainactivity
Using alarm manager Every 5 minutes
My Asynctask
is kept in a New Service Class.
Using that Asynctask
I'm retrieving String values from Web service.
Retrieving from web Service Saving in String
Array
Works fine.
Problem:
I want pass that String Array value from Web service doInBackground
to Mainactivity is Getting Null.
Help me how to achieve this.
link i refered ,but no success
private class AsyncCallWSfor_SERVICE extends AsyncTask<String, Void, Void>
{
@Override
protected Void doInBackground(String... params)
{
Log.i(TAG1, "doInBackground");
try
{
getdatafromWeb();
}
catch (Exception e)
{
Toast.makeText(getApplicationContext(),
"error caught in do in background", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
return null;
}
@Override
protected void onPreExecute()
{
/* //progress.setTitle("Progress");
progress.setMessage("Please Wait Loading Data...");
progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progress.setIndeterminate(true);
progress.show();*/
Log.i(TAG1, "onPreExecute");
}
@Override
protected void onPostExecute(Void result)
{
// To dismiss the dialog
// progress.dismiss();
Log.i(TAG1, "onPostExecute");
}
}
public void getdatafromWeb() {
// Create request
SoapObject request = new SoapObject(NAMESPACE1, METHOD_NAME1);
// Create envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
// Set output SOAP object
envelope.setOutputSoapObject(request);
// Create HTTP call object
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL1);
try {
// Invole web service
androidHttpTransport.call(SOAP_ACTION1, envelope);
// Get the response
SoapPrimitive response1 = (SoapPrimitive) envelope.getResponse();
//Converting string to Array list
ArrayList<String> KitDistributedString_array= new ArrayList<String>();
if ((response1.toString()).contains("{")) {
SoapObject rep = (SoapObject) envelope.bodyIn;
JSONArray jr = new JSONArray(rep.getPropertyAsString(0)
.toString());
for (int i = 0; i < jr.length(); i++) {
JSONObject jb = (JSONObject) jr.get(i);
KitValueString = jb.getString("KitValue");
Log.d(TAG1 +"MY Data" , KitValueString);
KitDistributedString_array.add(KitValueString);
}
STRING_ARRAY = new String[KitDistributedString_array.size()];
STRING_ARRAY = KitDistributedString_array.toArray(STRING_ARRAY);
}
else
{
Status_Response_Service = response1.toString();
}
} catch (Exception e) {
e.printStackTrace();
}
}
I want to pass this STRING_ARRAY to MainActivity