// Stops the background thread and its {@link Handler}. private void StopBackgroundThread() { BackgroundThread.QuitSafely(); try { BackgroundThread.Join(); BackgroundThread = null; BackgroundHandler = null; } catch (InterruptedException e) { e.PrintStackTrace(); } }