From ce4684ad9618f063abf3eb4a42cb81361a17be1d Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sun, 23 Feb 2014 12:05:26 -0800 Subject: Fix issue with handler not being initialized in some cases --- src/github/daneren2005/dsub/util/BackgroundTask.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') 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 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 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() { -- cgit v1.2.3