altosdroid: do service start/bind/unbind in start/stop, not create/destroy.
authorMike Beattie <mike@ethernal.org>
Tue, 28 Aug 2012 10:09:34 +0000 (22:09 +1200)
committerMike Beattie <mike@ethernal.org>
Tue, 28 Aug 2012 10:09:34 +0000 (22:09 +1200)
Signed-off-by: Mike Beattie <mike@ethernal.org>
altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java

index 8e63f6305773617fac8fedaca6d2ef1b0b254ac5..437369e22e2a26343058bbb22bb029289265266c 100644 (file)
@@ -202,10 +202,6 @@ public class AltosDroid extends Activity {
                        }
                });
 
-               // Start Telemetry Service
-               startService(new Intent(AltosDroid.this, TelemetryService.class));
-
-               doBindService();
        }
 
        @Override
@@ -217,13 +213,17 @@ public class AltosDroid extends Activity {
                        Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
                        startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
                }
+
+               // Start Telemetry Service
+               startService(new Intent(AltosDroid.this, TelemetryService.class));
+
+               doBindService();
        }
 
        @Override
        public synchronized void onResume() {
                super.onResume();
                if(D) Log.e(TAG, "+ ON RESUME +");
-
        }
 
        @Override
@@ -236,17 +236,16 @@ public class AltosDroid extends Activity {
        public void onStop() {
                super.onStop();
                if(D) Log.e(TAG, "-- ON STOP --");
+
+               doUnbindService();
        }
 
        @Override
        public void onDestroy() {
                super.onDestroy();
-
-               doUnbindService();
+               if(D) Log.e(TAG, "--- ON DESTROY ---");
 
                if (tts != null) tts.shutdown();
-
-               if(D) Log.e(TAG, "--- ON DESTROY ---");
        }