Wednesday 15 May 2013

android - Multiple Async Tasks for post in same activity -


I've written those threads:

but no answer to my question Found, someone may help you ..

I have an Android app that posts logs and Jason gives feedback, if Jason is okay then I can get another response. Must have to post second data.

I have expanded the Ashink class which is posting on the URL:

  Public class AsyncHttpPost asyncnask and string, string, string & gt; {Private Hashmap & lt; String, string & gt; MData = null; Public asynchronous HTTP post (hashmap> string, string & gt; data) {mData = data; } @ Override protected string doInBackground (string ... parameter) {byte [] result = null; String str = ""; HTTP Client Client = New DefaultHttpClient (); Http post post = new html post (parameter [0]); // In this case, try the parameter [0] URL {ELLILT   

Now - if there is a status error then I need to get another post. Do I need to create another async class? With all the procedures? This problem is different only onPostExecute part. In fact, "doInBackground" will always be the same ..

Any ideas how can I easily make multiple posts in the same activity?

First of all, because your doInBackground () code always remains the same , I suggest that you take it into a common utility class

In addition, you can go one by two ways:

  1. For each type of request Create a new asyncuscope that can call your utility class, and your own OnPostExecute ()
  2. An asinka task has a flag in it, which is called onPostExecute ( ) method how the code should be executed. You must give the flag as a parameter in the constructor or in the execution.

No comments:

Post a Comment