From 5190cf7a9b1db1ef0d7cac007ce73aff248203f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjetil=20=C3=98rbekk?= Date: Mon, 13 Feb 2012 20:08:38 +0100 Subject: Fix network notification. NetworkNotificationListener in SameService passes networks correctly to listening activity. Activity displays networks. --- .../src/main/java/com/orbekk/SameService.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'same-android/src/main/java/com') diff --git a/same-android/src/main/java/com/orbekk/SameService.java b/same-android/src/main/java/com/orbekk/SameService.java index 18d7dee..305bf44 100644 --- a/same-android/src/main/java/com/orbekk/SameService.java +++ b/same-android/src/main/java/com/orbekk/SameService.java @@ -41,13 +41,20 @@ public class SameService extends Service { private SameController sameController = null; private Configuration configuration = null; + // A list with alternating network names and urls. + private ArrayList availableNetworks = new ArrayList(); + private NetworkNotificationListener networkListener = new NetworkNotificationListener() { @Override public void notifyNetwork(String networkName, String masterUrl) { - Message message = Message.obtain(); - message.obj = "notifyNetwork(" + networkName + ")"; - toastHandler.sendMessage(message); + logger.info("notifyNetwork({})", networkName); + availableNetworks.add(networkName); + availableNetworks.add(masterUrl); + Intent intent = new Intent(AVAILABLE_NETWORKS_UPDATE); + intent.putStringArrayListExtra(AVAILABLE_NETWORKS, + availableNetworks); + sendBroadcast(intent); } }; @@ -68,13 +75,6 @@ public class SameService extends Service { Toast.makeText(SameService.this, (String)message.obj, Toast.LENGTH_SHORT) .show(); - - Intent intent = new Intent(AVAILABLE_NETWORKS_UPDATE); - ArrayList networkList = new ArrayList(); - networkList.add("FirstNetwork"); - intent.putStringArrayListExtra(AVAILABLE_NETWORKS, - networkList); - sendBroadcast(intent); break; case SEARCH_NETWORKS: logger.info("SEARCH_NETWORKS"); -- cgit v1.2.3