task.disconnect(); } public void resetTask() { task = new SampleTask(); restartButton.setEnabled(true); } public void startPendingTask(View startButton) { // register this activity with the task task.connect(this); if (task.isPending()) { // task has not been started yet, start it task.execute(); } restartButton.setEnabled(task.isFinished()); }