diff options
Diffstat (limited to 'same-android/src/main/java/com/orbekk')
-rw-r--r-- | same-android/src/main/java/com/orbekk/same/SameService.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/same-android/src/main/java/com/orbekk/same/SameService.java b/same-android/src/main/java/com/orbekk/same/SameService.java index 53742bd..55fb17c 100644 --- a/same-android/src/main/java/com/orbekk/same/SameService.java +++ b/same-android/src/main/java/com/orbekk/same/SameService.java @@ -111,10 +111,19 @@ public class SameService extends Service { private StateChangedListener stateListener = new StateChangedListener() { @Override public void stateChanged(Component component) { + ArrayList<Messenger> dropped = new ArrayList<Messenger>(); for (Messenger messenger : stateReceivers) { Message message = Message.obtain(null, UPDATED_STATE_MESSAGE); message.obj = component; + try { + messenger.send(message); + } catch (RemoteException e) { + logger.warn("Failed to send update. Dropping state receiver."); + e.printStackTrace(); + dropped.add(messenger); + } } + stateReceivers.removeAll(dropped); } }; @@ -168,6 +177,8 @@ public class SameService extends Service { try { sameController.start(); sameController.getClient().setNetworkListener(networkListener); + sameController.getClient().getInterface() + .addStateListener(stateListener); } catch (Exception e) { logger.error("Failed to start server", e); } |