As below code shows I have a function named record()
I want to call this function with asynctask but I do not know how to work with asynctask, record function takes
Try this-
public class Record extends Activity {
MediaPlayer mp;
String name;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.record);
mp = new MediaPlayer();
new Task1().execute();
}
class Task1 extends AsyncTask<Void, Void, String> {
@Override
protected void onPreExecute()
{
super.onPreExecute();
}
@Override
protected String doInBackground(Void... arg0)
{
//Record method
}
@Override
protected void onPostExecute(String result)
{
super.onPostExecute(result);
}
}
}
Make AsyncTask
Class and write code there and call your AsyncTask
Class by new AsyncTaskClass().execute();
Try below code for your reference.
public void record() {
new AsyncTask<Void, Void, Void() {
@Override
protected void doInBackground(Void... params) {
}
Override
protected void onPostExecute(ArrayList<HashMap<String, String>> result) {
}
}.execute();
}