---
title: "How to use asynctask in android and how to call asynctype class."  
description: "How to use asynctask in android and how to call asynctype class."  
author: "Anonymous User"  
published: 2015-02-20  
updated: 2015-02-20  
canonical: https://www.mindstick.com/forum/12969/how-to-use-asynctask-in-android-and-how-to-call-asynctype-class  
category: "android"  
tags: ["android controls"]  
reading_time: 1 minute  

---

# How to use asynctask in android and how to call asynctype class.

How to use [asynctask](https://www.mindstick.com/forum/158886/what-is-the-purpose-of-asynctask-in-android-and-when-should-it-be-used) in [android](https://www.mindstick.com/articles/13046/10-reasons-why-i-prefer-android-vs-iphone-ios) and how to call asynctype [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp)

## Replies

### Reply by Anonymous User

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" });
```


---

Original Source: https://www.mindstick.com/forum/12969/how-to-use-asynctask-in-android-and-how-to-call-asynctype-class

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
