From 16dfacf8c100d5ba0595694b828b77018266616a Mon Sep 17 00:00:00 2001 From: Sam Duke Date: Tue, 31 Mar 2015 17:58:59 +0100 Subject: [PATCH 1/3] Always deliver scan/ranging results on the main thread --- .../org/altbeacon/beacon/BeaconIntentProcessor.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/org/altbeacon/beacon/BeaconIntentProcessor.java b/src/main/java/org/altbeacon/beacon/BeaconIntentProcessor.java index bb2e30ec2..3dbc10a71 100644 --- a/src/main/java/org/altbeacon/beacon/BeaconIntentProcessor.java +++ b/src/main/java/org/altbeacon/beacon/BeaconIntentProcessor.java @@ -44,6 +44,19 @@ public BeaconIntentProcessor() { @Override protected void onHandleIntent(Intent intent) { + //Make sure we always deliver results on the main thread + if (Looper.getMainLooper().getThread() != Thread.currentThread()) { + Handler mainHandler = new Handler(Looper.getMainLooper()); + + Runnable myRunnable = new Runnable() { + @Override + public void run() { + onHandleIntent(intent) + } + }; + mainHandler.post(myRunnable); + return; + } LogManager.d(TAG, "got an intent to process"); MonitoringData monitoringData = null; From 9985c527039e3fd39de12af173197d281780d2be Mon Sep 17 00:00:00 2001 From: Sam Duke Date: Tue, 31 Mar 2015 18:09:26 +0100 Subject: [PATCH 2/3] added missing imports --- src/main/java/org/altbeacon/beacon/BeaconIntentProcessor.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/altbeacon/beacon/BeaconIntentProcessor.java b/src/main/java/org/altbeacon/beacon/BeaconIntentProcessor.java index 3dbc10a71..d0aa1f36f 100644 --- a/src/main/java/org/altbeacon/beacon/BeaconIntentProcessor.java +++ b/src/main/java/org/altbeacon/beacon/BeaconIntentProcessor.java @@ -27,6 +27,9 @@ import org.altbeacon.beacon.service.MonitoringData; import org.altbeacon.beacon.service.RangingData; +import android.os.Handler; +import android.os.Looper; + import android.annotation.TargetApi; import android.app.IntentService; import android.content.Intent; From c07556f310b3d2ee421bc26a77255375d0106aa1 Mon Sep 17 00:00:00 2001 From: Sam Duke Date: Tue, 31 Mar 2015 18:21:14 +0100 Subject: [PATCH 3/3] add missing semi-colon --- src/main/java/org/altbeacon/beacon/BeaconIntentProcessor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/altbeacon/beacon/BeaconIntentProcessor.java b/src/main/java/org/altbeacon/beacon/BeaconIntentProcessor.java index d0aa1f36f..1ac286b3f 100644 --- a/src/main/java/org/altbeacon/beacon/BeaconIntentProcessor.java +++ b/src/main/java/org/altbeacon/beacon/BeaconIntentProcessor.java @@ -54,7 +54,7 @@ protected void onHandleIntent(Intent intent) { Runnable myRunnable = new Runnable() { @Override public void run() { - onHandleIntent(intent) + onHandleIntent(intent); } }; mainHandler.post(myRunnable);