Home > DeveloperSection > Forums > Calling an activity class from Async class
Tanuj Kumar

Total Post:134

Points:940
Posted on    March-20-2015 3:03 AM

 Android Android  Synchronization 
Ratings:


 1 Reply(s)
 611  View(s)
Rate this:

My code is-:

private class AsyncCallWS extends AsyncTask<String, Void, Void> {

                 @Override

                 protected Void doInBackground(String... params) {

                     //Invoke webservice

                     vaildUserId = WebService.invokeAuthenticateUserWS(loginUserName, loginPassword, "AuthenticateUser");

}



Manoj Pandey

Total Post:26

Points:188
Posted on    March-20-2015 3:31 AM

When an asynchronous task is executed, the task goes through 4 steps:

1.      onPreExecute(), invoked on the UI thread before the task is executed.

2.      doInBackground(Params...), invoked on the background thread immediately after onPreExecute() finishes executing.

3.      onProgressUpdate(Progress...), invoked on the UI thread after a call to publishProgress(Progress...).

4.      onPostExecute(Result), invoked on the UI thread after the background computation finishes.

Add following code

 

   protected void onPostExecute(Void result)

   {

       // TODO Auto-generated method stub

       super.onPostExecute(result);

       Intent myIntent=new Intent(this, MyActivity.class);

       startActivity(myIntent);

       finish();

   }

 


Modified On Mar-20-2015 03:32:14 AM

Don't want to miss updates? Please click the below button!

Follow MindStick