diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-02-13 20:03:12 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-02-13 20:03:12 +0100 |
commit | 6837a4482f1b922962028010ce690146b4aef349 (patch) | |
tree | 8be96a68910188ad84f5a9846855d0ef83b2ed0b /same-android/src/main/java/com/orbekk | |
parent | f812594f57fee17f03fe8082e7b39b20bf3f6288 (diff) |
Make Android app behave.
Doing things slightly more correctly.
Diffstat (limited to 'same-android/src/main/java/com/orbekk')
-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( |