// Begin BT communicaction thread private void beginCommunication(BluetoothSocket socket) { Log.i(TAG, "BonitorActivity - beginComunication()"); // Begin Bluetooth Communication if (communicationThread != null) { communicationThread.cancel(); } communicationThread = new CommunicationThread(socket); communicationThread.start(); }
// Back button pressed @Override public void onBackPressed() { Log.e(TAG, "BonitorActivity - onBackPressed()"); if (connectionThread != null) { connectionThread.cancel(); } if (communicationThread != null) { communicationThread.cancel(); } if (fileWriter != null) { try { fileWriter.close(); } catch (IOException e) { e.printStackTrace(); } } finish(); }
// onDestroy @Override protected void onDestroy() { Log.e(TAG, "BonitorActivity - onDestroy()"); super.onDestroy(); if (connectionThread != null) { connectionThread.cancel(); } if (communicationThread != null) { communicationThread.cancel(); } if (fileWriter != null) { try { fileWriter.close(); } catch (IOException e) { e.printStackTrace(); } } finish(); }