【问题标题】:Microsoft Band Android Tile XMLMicrosoft Band Android Tile XML
【发布时间】:2015-11-03 01:49:45
【问题描述】:

我正在使用 Microsoft SDK 和 Android Studio 为 Band 2 开发应用程序。我已在我的设备上成功测试了该应用程序,但我遇到的问题是应用程序如何链接到磁贴以及该磁贴如何添加到健康应用程序。

表示 XML 驻留在哪里?我阅读了 Microsoft Band SDK.pdf 第 8.8 节简单自定义瓷砖示例。该示例未指定代码需要驻留的位置。我是否需要将其添加到应用程序的类文件或不同的文件中?磁贴图标是在哪里创建的,在 Android Studio 中,如果是,在哪里创建?

类、tile xml 和图标如何安装到乐队的示例会很好。

谢谢!

【问题讨论】:

    标签: android tile microsoft-band


    【解决方案1】:

    SDK 包含一些示例 - 查看名为 BandTileEvent 的示例以了解完整的实现。快速版本是您的图块创建代码应在创建时创建一系列布局(包含具有 ID 的元素)和图标,然后更新您将选择布局并为元素的 ID 分配值。示例中的关键元素如下所示(为便于阅读而进行了修改):

    private PageLayout createButtonLayout() {
        return new PageLayout(
                new FlowPanel(15, 0, 260, 105, FlowPanelOrientation.VERTICAL)
                    .addElements(new FilledButton(0, 5, 210, 45).setMargins(0, 5, 0 ,0).setId(12).setBackgroundColor(Color.RED))
                    .addElements(new TextButton(0, 0, 210, 45).setMargins(0, 5, 0 ,0).setId(21).setPressedColor(Color.BLUE))
                );
    }
    

    这将创建一个用于平铺创建过程的 PageLayout 对象。这个方法应该这样使用:

        BandTile tile = new BandTile.Builder(YOUR_TILE_UUID, "Tile Title", tileIconBitmap)
            .setPageLayouts(createButtonLayout())
            .setPageIcons(getIconsToUse())
            .build();
        client.getTileManager().addTile(context, tile);
    

    一旦磁贴在乐队上,您需要发送更新 - 它应该看起来像这样:

    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")));
    }
    

    一旦磁贴在您的频段上,您就可以注册一个返回这些事件的意图过滤器。检查 SDK 示例以了解所使用的确切意图 - 当磁贴打开、关闭以及按下其上的按钮时,您会收到通知。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多