PhilipsHueSDK-Java-MultiPlatform-Android icon indicating copy to clipboard operation
PhilipsHueSDK-Java-MultiPlatform-Android copied to clipboard

Connect twice in one app

Open tomu1907 opened this issue 10 years ago • 1 comments

Hi,

I have some special requirements.. ;)

I have an app which is connecting to the bridge as usual -> means that I implemented the connection like in the example (http://www.developers.meethue.com/documentation/java-sdk-getting-started#connectingToABridge). My app is using a BroadcastReceiver, so it is waking if some events come up. Is this BroadcastReceiver I want to connect to the bridge and do some color changes. The problem is now that it is sometimes not possible to connect because the other part of the app is already connected to the bridge. I get no error message but it seems to be that the method phHueSDK.isAccessPointConnected(lastAccessPoint) is hanging and do nothing.

Any suggestions how to solve these multiple connect to one bridge?

Thanks! tomu

tomu1907 avatar Jul 25 '15 07:07 tomu1907

Hi tomu,

It's a bit tricky this one without seeing your code. Nothing immediately springs to mind. The PHHueSDK is a singleton, so what you are doing should work in theory, providing you have not disconnected from the SDK.

The isAccessPointConnected method loops through the connected bridges, comparing the IP Address in the Bridge Config with the IP Address in the passed lastAccessPoint object. I can't really see how this can hang. Are you sure you are not getting any Exceptions/Errors in LogCat?

When the BroadcastReceiver wakes up, can you add a check to see if PHHueSDK.getInstance().getSelectedBridge() is null or not This will at least test to see if your PHSDK singleton is still alive.

Steve

SteveyO avatar Jul 31 '15 09:07 SteveyO