@Override
 public void onTerminate() {
   super.onTerminate();
   // Stop the connection services
   if (mBluetoothConnectionService != null) mBluetoothConnectionService.stop();
   if (mWiFiConnectionService != null) {
     mWiFiConnectionService.stop();
     mWiFiConnectionService = null;
   }
   stopService(intent);
   mLogArrayAdapter.clear();
   Log.i(TAG, "onTerminated");
 }
 public void stopService() {
   if (mBluetoothConnectionService != null) mBluetoothConnectionService.stop();
   if (mWiFiConnectionService != null) mWiFiConnectionService.stop();
 }