Reputation: 21
i am messing around with developing apps for the Band 2 using the Microsoft SDK and the Android Studio. I have successfully tested the application on my device but the problem i am having is how the application gets linked to the tile and how that tile gets added to the health app.
Where does the presentation XML reside? I read the Microsoft Band SDK.pdf section 8.8 SIMPLE CUSTOM TILE EXAMPLE. The example does not specify where the code needs to reside. Do i need to add it to the class file for the app or in a different file? Where does the tile icon get created, in the Android Studio and if so where?
An example of how the class, tile xml, and icon get installed to the band would be nice.
Thanks!
Upvotes: 0
Views: 131
Reputation: 383
The SDK includes some samples- have a look at the one entitled BandTileEvent to see the full implementation. The quick version is that your tile creation code should create a series of layouts (containing elements with IDs) and icons when it is made, and then to update you'll choose a layout and assign values to the elements' ids. The key elements from the samples look like this (modified for easy readability):
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))
);
}
This will create a PageLayout object that is used in the tile creation process. This method should be used like this:
BandTile tile = new BandTile.Builder(YOUR_TILE_UUID, "Tile Title", tileIconBitmap)
.setPageLayouts(createButtonLayout())
.setPageIcons(getIconsToUse())
.build();
client.getTileManager().addTile(context, tile);
Once the tile is on the band, you'll need to send an update- it should look something like this:
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")));
}
Once the tile is on your band, you can register an intent filter that will return these events. Check the SDK samples for the exact intents used- you'll get notified when the tile is opened, closed, and when buttons on it are pressed.
Upvotes: 0