public static void executeTask() { progressBar.setIndeterminate(true); progressBar.setVisibility(View.VISIBLE); if (newTask == null) { // a task can be executed only once // Exec async load task newTask = new AsyncListViewLoader(); newTask.execute("https://api.github.com/zen?access_token=?_TOKEN_?"); } else if (newTask.getStatus() != AsyncTask.Status.RUNNING) { newTask = new AsyncListViewLoader(); newTask.execute("https://api.github.com/zen?access_token=?_TOKEN_?"); } }
public void onDestroy() { if (newTask != null) { newTask.cancel(true); } super.onDestroy(); }