My async task call is within the onCreate() method of my activity
my_random_task = new MyRandomTask();
my_random_task.setListener(this);
final Button post_btn = (Button) findViewById(R.id.post_btn);
post_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText post_text = (EditText) findViewById(R.id.post_text);
if (!post_text.isEmpty()) {
summoner_search_task.execute(summoner_name);
}else{
Toast.makeText(getApplicationContext(), "Please type a post text.", Toast.LENGTH_SHORT).show();
post_text.requestFocus();
}
}
});
The asynctask is empty but when i try to call the asynctask again by pressing the button i get
java.lang.IllegalStateException: Cannot execute task: the task has already been executed (a task can be executed only once)
Is there any way to make the asynctask reset and be able to run again after i press the button?