Microsoft Band Using the SDK (Android)

0 456

Microsoft Band is a new health and fitness tracker which was announced back in October 2014. This Band helps you to accomplish your health objectives by tracking your hear rate, steps, calories burn and sleep quality and keeps you updated with email reviews and calender alerts.  Other then health objectives, it can take notes, setup updates with your voice utilizing Cortana  “the personal assistance in windows phone”. All important incoming calls, sms, social updates, weather updates are at you writs.

It has a bright full color touch screen, dust and water resistance. Microsoft Band works with Windows Phone, Android and iPhone.

We can develop APPS for the Microsoft Band for all the platforms. For each platform there are few requirements to start using the Band SDK. We will learn that how we can connect the Band to and Android Phone.


  • Microsoft Band SDK (Android Platform can be downloaded from here).
  • Android Studio or Eclipse Installed

Once the SDK is downloaded you need to add it into your android project under your libs directory.

Then you need to make changes in your AndroidManifest.xml file. Please note that the minimum Android API Support is 17 so you will need to update the minimum support in your AndroidManifest.xml file and add the following using permissions.

 <uses-permission android:name="android.permission.BLUETOOTH" /> 

<uses-permission android:name="" /> 

Connecting to a Band

To make a connection to Band, the following requirements should be true.

  • The band is paired with the device your application is running on
  • The band is connected currently to the same device .

Once above requirements are true you can get the list of paired bands using the BandClientManager and establish connection to anyone of the paired bands.

Step 1:

Import the correct Packages







Step 2:

You need to get the list of all the paired bands to the device.

 BandDeviceInfo[] pairedBands = BandClientManager.getInstance.getPairedBands(); 


Step 3:

Create a BandClient object. This object is responsible for the further interactions with the Band.

 BandClient client =BandClientManager.getInstance.create(getApplicationContext()), pairedBands[0]); 

Step 4:

You need to perform this task in a background thread. If this task is performed on a UI layer the application will crash. Use AsyncTask to perform this action.
 BandPendingResult<ConnectionResult> pendingResult = bandClient.connect();

try {

ConnectionResult result = pendingResult.await();

if(result == ConnectionResult.OK)


// do work on success


else {

// do work on failure



catch(InterruptedException ex) {

// handle InterruptedException

}catch(BandException ex) {

// handle BandExceptio


Here is how you can setup the background task for the connection process.

 public class ConnectBand extends AsyncTask<String, String, String> {


protected void onPreExecute() {

// TODO Auto-generated method stub



// set the pre task actions here. for example showing a loading dialog box



protected String doInBackground(String... result) {


String reponseMessage = ""


// in the backgroud task set up the response message and Boolean varible to check the connection status with the band


//perform step 2, step 3 and step 4 tasks here


//under appropriate conditions set the appropriate responseMessage and set the Boolean connection status to true and false


//further more you can get the Firmware Version and Hardware Version once you are connected to the band as follow


//perform this step in the if condition of Step4


String fwVersion = null;

String hwVersion = null;

try {

BandPendingResult<String> getBandInfo = clients


fwVersion = getBandInfo.await();

getBandInfo = clients.getHardwareVersion();

hwVersion = getBandInfo.await();

// do work related to band firmware & hardware versions

responseMessage = "Band Connected"+"\nHardware Version : "+hwVersion+"\n Firmware Version : "+fwVersion;

} catch (InterruptedException ex) {

// handle InterruptedException

} catch (BandException ex) {

// handle BandException



}//end of background


protected void onPostExecute(String result) {

// TODO Auto-generated method stub


//int he post execute method you can display the status message weather you are connected to band or not.

//make use of Boolean variable here. Check if the variable returned a true value you can display the Band Info i-e Firmware Information and Hardware Information


//and perform other task as 1. Accessing the Band Sensor, 2. Personalizing your Band , 3. Sending messages to Band and more

Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG)



}//end of post execute


}//end of class 
  • Design

Leave A Reply

Your email address will not be published.