I’ve got AsyncTask in my Activity, when user clicks button, I start an AsyncTask:
@Override
public void onClick(View view) {
switch(view.getId()){
case R.id.btnLogin:
if(task==null){
task=new LoginTask(this);
task.execute();
}
break;
}
}
But if user clicks button after task is completed, I want it to be executed one more time. What should I do accomplish this? Should I create new task every time user clicks button? Is it OK to create new instance if task is already running?
Also, task is static inner class, in order to handle screen rotation.
Declare task as a class variable.And in the postExecute of AsynchTask make it null.Probably you are done