Exemplo n.º 1
0
  @Override
  protected void onStop() {
    super.onStop();

    // Disconnect from the remote device and close the serial port
    bluetoothSerial.stop();
  }
Exemplo n.º 2
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_connect) {
      showDeviceListDialog();
      return true;
    } else if (id == R.id.action_disconnect) {
      bluetoothSerial.stop();
      return true;
    } else if (id == R.id.action_crlf) {
      crlf = !item.isChecked();
      item.setChecked(crlf);
      return true;
    }

    return super.onOptionsItemSelected(item);
  }