for (AltosDroidTab mTab : mTabs)
mTab.update_ui(state, from_receiver, location, mTab == mTabsAdapter.currentItem());
- if (state != null)
+ if (state != null && mAltosVoice != null)
mAltosVoice.tell(state, from_receiver);
saved_state = state;
mStateLayout = (RelativeLayout) findViewById(R.id.state_container);
mStateView = (TextView) findViewById(R.id.state_value);
mAgeView = (TextView) findViewById(R.id.age_value);
-
- mAltosVoice = new AltosVoice(this);
}
@Override
doBindService();
+ if (mAltosVoice == null)
+ mAltosVoice = new AltosVoice(this);
}
@Override
if(D) Log.e(TAG, "-- ON STOP --");
doUnbindService();
+ if (mAltosVoice != null) {
+ mAltosVoice.stop();
+ mAltosVoice = null;
+ }
}
@Override
}
}
+ 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();
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: