summaryrefslogtreecommitdiff
path: root/same-android/src
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-25 22:52:52 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-25 22:52:52 +0100
commit05383f1ba3298c20c97a3976ed303016c3a6e9f3 (patch)
treefa7a9298ddf77329ae754038f0b080fae229ec19 /same-android/src
parentbfa3a4fad59027e64cf6a4667d29b3f069859954 (diff)
Send messages correctly.
Diffstat (limited to 'same-android/src')
-rw-r--r--same-android/src/main/java/com/orbekk/same/SameService.java11
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);
}