diff options
-rw-r--r-- | same-android/src/main/java/com/orbekk/SameControllerActivity.java | 7 | ||||
-rw-r--r-- | same-android/src/main/java/com/orbekk/SameService.java | 16 |
2 files changed, 15 insertions, 8 deletions
diff --git a/same-android/src/main/java/com/orbekk/SameControllerActivity.java b/same-android/src/main/java/com/orbekk/SameControllerActivity.java index c8c1ebd..a2d5688 100644 --- a/same-android/src/main/java/com/orbekk/SameControllerActivity.java +++ b/same-android/src/main/java/com/orbekk/SameControllerActivity.java @@ -115,14 +115,14 @@ public class SameControllerActivity extends Activity { setContentView(R.layout.controller); showIpAddress(); - - Intent intent = new Intent(this, SameService.class); - bindService(intent, sameConnection, Context.BIND_AUTO_CREATE); } @Override public void onStart() { super.onResume(); + Intent intent = new Intent(this, SameService.class); + bindService(intent, sameConnection, Context.BIND_AUTO_CREATE); + IntentFilter sameServiceUpdates = new IntentFilter( SameService.AVAILABLE_NETWORKS_UPDATE); registerReceiver(broadcastReceiver, sameServiceUpdates); @@ -133,6 +133,7 @@ public class SameControllerActivity extends Activity { if (sameService != null) { unbindService(sameConnection); } + unregisterReceiver(broadcastReceiver); } @Override diff --git a/same-android/src/main/java/com/orbekk/SameService.java b/same-android/src/main/java/com/orbekk/SameService.java index beb230f..18d7dee 100644 --- a/same-android/src/main/java/com/orbekk/SameService.java +++ b/same-android/src/main/java/com/orbekk/SameService.java @@ -100,6 +100,7 @@ public class SameService extends Service { @Override public IBinder onBind(Intent intent) { + logger.info("onBind()"); return messenger.getBinder(); } @@ -109,17 +110,22 @@ public class SameService extends Service { // TODO: Move this to the bound interface. - if (intent.getAction().equals("create")) { - } else if (intent.getAction().equals("join")) { - String masterUrl = intent.getExtras().getString("masterUrl"); - sameController.joinNetwork(masterUrl); - } +// if (intent.getAction().equals("create")) { +// } else if (intent.getAction().equals("join")) { +// String masterUrl = intent.getExtras().getString("masterUrl"); +// sameController.joinNetwork(masterUrl); +// } return START_STICKY; } @Override public void onCreate() { logger.info("onCreate()"); + + // Ensure service is started. + Intent intent = new Intent(this, getClass()); + startService(intent); + if (sameController == null) { initializeConfiguration(); sameController = SameController.create( |