Microsoft Band and Android(Java) – Connect to the Band

Published on May 17, 2015 by abundantcode

Filed under Java

Last modified May 17, 2015

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 6527 times

Below is the sample code snippet demonstrating how to connect to the first microsoft band that is paired using the BandInfo and BandClient object.

How to Connect to the Microsoft Band from android application using Java ?

How to get the list of paired bands from the android application using java.

import com.microsoft.band.BandClient;
import com.microsoft.band.BandClientManager;
import com.microsoft.band.BandException;
import com.microsoft.band.BandInfo;
import com.microsoft.band.BandIOException;
import com.microsoft.band.ConnectionState;

public class BandManager
{
    public BandInfo[] GetPairedBands()
    {
        return BandClientManager.getInstance().getPairedBands();
    }
    public BandClient GetBandClientObject()
    {
        BandClient bandClient =
BandClientManager.getInstance().create(getActivity(), pairedBands[0]);
        return bandClient;

    }
    public void Connect()
    {
        BandPendingResult<ConnectionState> result =
        bandClient.connect();
        ConnectionState state = result.await();
        if(state == ConnectionState.CONNECTED) 
        {
            // Band is connected . Perform your logic after connection.
        }

    }        
}

Leave a Comment


x

You might be Interested in these Posts

Video - Angular Router - Brian Ford

Video - Angular Router - Brian Ford http://www.youtube.com/watch?v=sfV0ApyN5fM ...

Video - An Angular2 Todo App: First look at App Development in Angular2

In this screencast , David East , one of the core contributor of the Angular provides a glimpse of A...

Video - Getting started with Angular 2

In this screencast , Alex Eagle , developer on the Angular team talks about Angular 2 developer prev...