private boolean addTile() throws Exception {
    if (doesTileExist(client.getTileManager().getTiles().await(), tileId)) {
      return true;
    }

    /* Set the options */
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inScaled = false;
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    Bitmap tileIcon =
        BitmapFactory.decodeResource(
            getBaseContext().getResources(), R.raw.drone_designer_icon, options);

    BandTile tile =
        new BandTile.Builder(tileId, "Drone", tileIcon)
            .setPageLayouts(createButtonLayout())
            .build();
    appendToUI("Button Tile is adding ...\n", 1);
    if (client.getTileManager().addTile(this, tile).await()) {
      appendToUI("Button Tile is added.\n", 1);
      return true;
    } else {
      appendToUI("Unable to add button tile to the band.\n", 1);
      return false;
    }
  }
  private boolean getConnectedBandClient() throws InterruptedException, BandException {
    if (client == null) {
      BandInfo[] devices = BandClientManager.getInstance().getPairedBands();
      if (devices.length == 0) {
        appendToUI("Band isn't paired with your phone.\n", 1);
        return false;
      }
      client = BandClientManager.getInstance().create(getBaseContext(), devices[0]);
    } else if (ConnectionState.CONNECTED == client.getConnectionState()) {
      return true;
    }

    appendToUI("Band is connecting...\n", 1);
    return ConnectionState.CONNECTED == client.connect().await();
  }
 private void unRegisterListeners() {
   try {
     client.getSensorManager().unregisterAllListeners();
   } catch (BandIOException e) {
     appendToUI(e.getMessage(), 1);
   }
 }
예제 #4
0
  private boolean getConnectedBandClient() throws BandException {
    if (client == null) {
      BandInfo[] devices = BandClientManager.getInstance().getPairedBands();
      if (devices.length == 0) {
        Log.e(TAG, "Band isn't paired with your phone.");
        return false;
      }
      client = BandClientManager.getInstance().create(context, devices[0]);
    } else if (ConnectionState.CONNECTED == client.getConnectionState()) {
      return true;
    }

    Log.i(TAG, "Band is connecting...");
    try {
      return ConnectionState.CONNECTED == client.connect().await();
    } catch (InterruptedException e) {
      return false;
    }
  }
 private void updatePages() throws BandIOException {
   client
       .getTileManager()
       .setPages(
           tileId,
           new PageData(pageId1, 0)
               .update(new FilledButtonData(12, Color.YELLOW))
               .update(new TextButtonData(21, "Text Button")));
   appendToUI("Send button page data to tile page \n\n", 1);
 }
  private boolean addTile() throws Exception {
    /* Set the options */
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inScaled = false;
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    Bitmap tileIcon =
        BitmapFactory.decodeResource(
            getBaseContext().getResources(), R.raw.tile_icon_large, options);
    Bitmap badgeIcon =
        BitmapFactory.decodeResource(
            getBaseContext().getResources(), R.raw.tile_icon_small, options);

    BandTile tile =
        new BandTile.Builder(tileId, "MessageTile", tileIcon).setTileSmallIcon(badgeIcon).build();
    appendToUI("Message Tile is adding ...\n");
    if (client.getTileManager().addTile(this, tile).await()) {
      appendToUI("Message Tile is added.\n");
      return true;
    } else {
      appendToUI("Unable to add message tile to the band.\n");
      return false;
    }
  }
 private void sendMessage(String title, String message) throws BandIOException {
   client
       .getNotificationManager()
       .sendMessage(tileId, title, message, new Date(), MessageFlags.SHOW_DIALOG);
   appendToUI(message + "\n");
 }