Home > DeveloperSection > Forums > How to use asynctask in android and how to call asynctype class.
Monaj Singh
Monaj Singh

Total Post:41

Points:287
Posted on    February-20-2015 6:27 AM

 Android Android Controls 
Ratings:


 1 Reply(s)
 541  View(s)
Rate this:
How to use asynctask in android and how to call asynctype class


sandy taylor
sandy taylor

Total Post:46

Points:324
Posted on    February-20-2015 6:31 AM

Create class and extends with AsyncTask

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

        @Override

         protected void onPreExecute() {

           // Write your code which run first

           // This code execute first

          // You can show Process dialog.

        }

        @Override

        protected String doInBackground(String... urls) {

             // write your code which you perform task in background.

            return null;

         }

         @Override

         protected void onPostExecute(String result) {

              // write your code which you perform task in after doInBackground()

         }

     }

Call Async type class

   MyAsyncData task = new MyAsyncData();

   task.execute(new String[] { "Sample" });


Modified On Feb-20-2015 06:33:49 AM

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

Follow MindStick