Example #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_measures);
    session = new SessionManager(getApplicationContext());

    // Instancie un nouvel objet Bluetooth
    bt = new Bluetooth(this);

    // Activer le Bluetooth
    bt.enableBluetooth();

    idPatient = session.getUserDetails();

    // Lance le graphique
    openChart();
  }
Example #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);
    }
  }