I have some work to do in the another thread (by doingAsyncTask).
Work start when user click on button. But at the same time
only one object of doingAsyncTask must do this work, i meen if doingAsyncTask is working, then click on button must not create a new object of doingAsyncTask and execute it, it must wait until work finish. How can i check it?
public class SearchActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//....
}
public void onclickButton(View view) {
new doingAsyncTask().execute();
}
public class doingAsyncTask extends AsyncTask<Void, Void, Void> {
protected Void doInBackground(Void... unused) {
//doing something
return(null);
}
protected void onProgressUpdate() {
}
protected void onPreExecute() {
}
protected void onPostExecute() {
}
}
}
SOLVED
thx all , its works for me
if(task.getStatus() == AsyncTask.Status.FINISHED)
task=new ProgressBarShow();
if(task.getStatus() == AsyncTask.Status.PENDING){
//task=new ProgressBarShow();
task.execute();
}
Check this AsyncTask.Status
code:
EDIT: