예제 #1
0
 @Override
 public void onBackPressed() {
   // Deconnexion de l'utilisateur
   session.logoutUser();
   if (btThread != null)
     // Arret du thread Bluetooth
     ((BtThread) btThread).close();
   super.onBackPressed();
 }
예제 #2
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        // Appuie sur l'icone Bluetooth
      case R.id.action_bt:
        item.setIcon(R.drawable.ic_action_bluetooth_searching);

        // Récupère le bon device
        bt.selectDevice();
        if (Bluetooth.device != null) {
          // Instanciation et lancement du thread Bluetooth
          btThread = new BtThread(Bluetooth.device, handler);
          btThread.start();

          // Instanciation de ArduinoData
          arduinoData = new ArduinoData(btThread, dataProcess, this);
          item.setIcon(R.drawable.ic_action_bluetooth_connected);
        }
        return true;

        // Affiche le graphique voulu
      case R.id.action_A:
        dataname = "A";
        cmpt = 0;
        openChart();
        return true;
      case R.id.action_B:
        dataname = "B";
        cmpt = 0;
        openChart();
        return true;
      case R.id.action_C:
        dataname = "C";
        cmpt = 0;
        openChart();
        return true;
      case R.id.action_O:
        dataname = "O";
        cmpt = 0;
        openChart();
        return true;
      case R.id.action_P:
        dataname = "P";
        cmpt = 0;
        openChart();
        return true;
      case R.id.action_R:
        dataname = "R";
        cmpt = 0;
        openChart();
        return true;
      case R.id.action_T:
        dataname = "T";
        cmpt = 0;
        openChart();
        return true;
      case R.id.deconnexion:
        onBackPressed();
        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }