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 Reply