altosdroid: begin adding TextToSpeech support.
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / TelemetryService.java
index 218c6d3378103c9f03dcbf74466af4ad626872ea..e3f0a739fd5d2a74acdc8494f6952e40ebc15627 100644 (file)
@@ -36,10 +36,6 @@ import android.os.RemoteException;
 import android.util.Log;
 import android.widget.Toast;
 
-// Need the following import to get access to the app resources, since this
-// class is in a sub-package.
-//import org.altusmetrum.AltosDroid.R;
-
 import org.altusmetrum.AltosLib.*;
 
 public class TelemetryService extends Service {
@@ -141,9 +137,14 @@ public class TelemetryService extends Service {
        }
 
        private void startAltosBluetooth(BluetoothDevice d) {
+               if (mAltosBluetooth == null) {
                        if (D) Log.i(TAG, "Connecting to " + d.getName());
                        mAltosBluetooth = new AltosBluetooth(d, mHandler);
                        setState(STATE_CONNECTING);
+               } else {
+                       stopAltosBluetooth();
+                       mHandler.sendMessageDelayed(Message.obtain(null, MSG_CONNECT, d), 1000);
+               }
        }
 
        private synchronized void setState(int s) {