@Override
    protected Void doInBackground(Void... params) {
      try {
        if (getConnectedBandClient()) {
          appendToUI("Band is connected.\n", 1);
          client
              .getSensorManager()
              .registerAccelerometerEventListener(mAccelerometerEventListener, SampleRate.MS128);
          client
              .getSensorManager()
              .registerGyroscopeEventListener(gyroscopeListener, SampleRate.MS128);
          client.getSensorManager().registerPedometerEventListener(pedometerListener);
          client.getSensorManager().registerDistanceEventListener(distanceListener);

          if (addTile()) {
            updatePages();
          }
        } else {
          appendToUI(
              "Band isn't connected. Please make sure bluetooth is on and the band is in range.\n",
              1);
        }
      } catch (BandException e) {
        String exceptionMessage = "";
        switch (e.getErrorType()) {
          case DEVICE_ERROR:
            exceptionMessage = "Please make sure bluetooth is on and the band is in range.";
            break;
          case UNSUPPORTED_SDK_VERSION_ERROR:
            exceptionMessage =
                "Microsoft Health BandService doesn't support your SDK Version. Please update to latest SDK.";
            break;
          case SERVICE_ERROR:
            exceptionMessage =
                "Microsoft Health BandService is not available. Please make sure Microsoft Health is installed and that you have the correct permissions.";
            break;
          case BAND_FULL_ERROR:
            exceptionMessage = "Band is full. Please use Microsoft Health to remove a tile.";
            break;
          default:
            exceptionMessage = "Unknown error occured: " + e.getMessage();
            break;
        }
        appendToUI(exceptionMessage, 1);

      } catch (Exception e) {
        appendToUI(e.getMessage(), 1);
      }
      return null;
    }
    @Override
    protected Void doInBackground(Void... params) {
      try {
        if (getConnectedBandClient()) {
          if (doesTileExist(client.getTileManager().getTiles().await(), tileId)) {
            sendMessage(title, message);
          } else {
            if (addTile()) {
              sendMessage("hint", "Send message to new message tile");
            }
          }
        } else {
          appendToUI(
              "Band isn't connected. Please make sure bluetooth is on and the band is in range.\n");
        }
      } catch (BandException e) {
        String exceptionMessage = "";
        switch (e.getErrorType()) {
          case DEVICE_ERROR:
            exceptionMessage = "Please make sure bluetooth is on and the band is in range.";
            break;
          case UNSUPPORTED_SDK_VERSION_ERROR:
            exceptionMessage =
                "Microsoft Health BandService doesn't support your SDK Version. Please update to latest SDK.";
            break;
          case SERVICE_ERROR:
            exceptionMessage =
                "Microsoft Health BandService is not available. Please make sure Microsoft Health is installed and that you have the correct permissions.";
            break;
          case BAND_FULL_ERROR:
            exceptionMessage = "Band is full. Please use Microsoft Health to remove a tile.";
            break;
          default:
            exceptionMessage = "Unknown error occured: " + e.getMessage();
            break;
        }
        appendToUI(exceptionMessage);

      } catch (Exception e) {
        appendToUI(e.getMessage());
      }
      return null;
    }