Using the beaconManager class in a non-activity class (unity plugin)

I'm currently making a unity plugin for the estimote beacons, so I can use them in my unity application.

To do this I call the java classes through the Java JNI support that is built into unity.

I have got the beaconManager set up in a non-activity class by passing in a reference to the current app context from the unityplayer class.

The beaconManager.setRangingListener(RangingListener) method throws me a runtime error saying that I can't create handler inside thread that has not called Looper.prepare()

If I call Looper.prepare() prior to the call then I don't get the runtime error, but the onBeaconsDiscovered is never called no matter my distance from the beacons.

I have called beaconManager.connect and the Service callback starts the ranging without throwing any exceptions and the error listener isn't picking up any errors. I have included the service in the manifest file along with the bluetooth permissions and have confirmed bluetooth is active via beaconManager.isBluetoothEnabled()

Has anyone done anything similar to this or knows how to solve this issue?

Hi Nic,

Did you ever resolve this problem? I know it was along time ago but I’m faced with exactly the same issue, albeit in a slightly different context.