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 | 16 |
1 files changed, 16 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 55fb17c..dad4b50 100644 --- a/same-android/src/main/java/com/orbekk/same/SameService.java +++ b/same-android/src/main/java/com/orbekk/same/SameService.java @@ -97,6 +97,7 @@ public class SameService extends Service { Messenger messenger = message.replyTo; if (messenger != null) { stateReceivers.add(messenger); + sendAllState(messenger); } else { logger.error("ADD_STATE_RECEIVER: Missing Messenger."); } @@ -127,6 +128,21 @@ public class SameService extends Service { } }; + private void sendAllState(Messenger messenger) { + State state = sameController.getClient().getInterface().getState(); + for (Component c : state.getComponents()) { + Message message = Message.obtain(null, UPDATED_STATE_MESSAGE); + message.obj = c; + try { + messenger.send(message); + } catch (RemoteException e) { + logger.warn("Failed to send state."); + e.printStackTrace(); + return; + } + } + } + private void initializeConfiguration() { Properties properties = new Properties(); String localIp = new Broadcaster(this) |