summaryrefslogtreecommitdiff
path: root/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2015-02-16 21:19:09 -0800
committerKeith Packard <keithp@keithp.com>2015-02-16 21:19:09 -0800
commit877609a60a9f2c61c1efad8285b2a3c22f59be28 (patch)
tree59def8e9ffdaeffaeeab1ab3b7632fb5d4e53d92 /altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
parentc51d39c7ea1153cd2d0dc02c47824a9f35b22fb9 (diff)
altosdroid: Explicitly disconnect BT on termination or 'disconnect'
This adds an explicit message to the telemetry service telling it when to stop trying to talk to the bluetooth device. Until this message is received, the service will reconnect to the specified BT device. That message is sent when you 'quit' the application, or when you 'disconnect'. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java')
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
index 10e735c8..273688d8 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
@@ -553,6 +553,13 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener {
}
}
+ private void disconnectDevice() {
+ try {
+ mService.send(Message.obtain(null, TelemetryService.MSG_DISCONNECT, null));
+ } catch (RemoteException e) {
+ }
+ }
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
@@ -610,9 +617,14 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener {
serverIntent = new Intent(this, DeviceListActivity.class);
startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
return true;
+ case R.id.disconnect:
+ /* Disconnect the bluetooth device
+ */
+ disconnectDevice();
+ return true;
case R.id.quit:
Log.d(TAG, "R.id.quit");
- stopService(new Intent(AltosDroid.this, TelemetryService.class));
+ disconnectDevice();
finish();
return true;
case R.id.select_freq: