title: Use asynctask to call a function in android
body: <p>As below code shows I have a function named <code>record()</code> I want to call this function with asynctask but I do not know how to work with asynctask, record function takes long to do some tasks so I need to use asynktsak.</p>
  
  <pre><code>public class Record extends Activity {
  
      MediaPlayer mp;
      String name;
  
      public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.record);
  
      mp = new MediaPlayer();
  
      record();
  
  }
  
  public void record() {
      .
      .
      .
    }
  }
  </code></pre>