diff options
-rw-r--r-- | src/github/daneren2005/dsub/util/BackgroundTask.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/util/BackgroundTask.java b/src/github/daneren2005/dsub/util/BackgroundTask.java index b9fe212f..fbeaea74 100644 --- a/src/github/daneren2005/dsub/util/BackgroundTask.java +++ b/src/github/daneren2005/dsub/util/BackgroundTask.java @@ -53,7 +53,7 @@ public abstract class BackgroundTask<T> implements ProgressListener { private static Handler handler = null; static { try { - handler = new Handler(); + handler = new Handler(Looper.getMainLooper()); } catch(Exception e) { // Not called from main thread } @@ -69,6 +69,13 @@ public abstract class BackgroundTask<T> implements ProgressListener { thread.start(); } } + if(handler == null) { + try { + handler = new Handler(Looper.getMainLooper()); + } catch(Exception e) { + // Not called from main thread + } + } } public static void stopThreads() { |