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 3908 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.
        }

    }        
}
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Comment


x

You might be Interested in these Posts

C Program to display Inverted half-pyramid using *

Problem Write a program in C to print Inverted half-pyramid using * as shown below.The program shou...

How to use array Rank in C# ?

In C# , the Rank property of the array is is used to get the rank of the array. In simple terms , ra...

How to hide virtual keyboard in android using Java?

There are times when you want to hide the virtual keyboard in android. You can easily do that using ...