本文整理汇总了Java中com.microsoft.band.ConnectionState.CONNECTED属性的典型用法代码示例。如果您正苦于以下问题:Java ConnectionState.CONNECTED属性的具体用法?Java ConnectionState.CONNECTED怎么用?Java ConnectionState.CONNECTED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.microsoft.band.ConnectionState
的用法示例。
在下文中一共展示了ConnectionState.CONNECTED属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConnectedBandClient
private boolean getConnectedBandClient() throws InterruptedException, BandException {
if (client == null) {
BandInfo[] devices = BandClientManager.getInstance().getPairedBands();
if (devices.length == 0 || id >= devices.length) {
Log.e("Requested Band isn't paired with your phone.");
return false;
}
Context c = SSJApplication.getAppContext();
client = BandClientManager.getInstance().create(c, devices[id]);
} else if (ConnectionState.CONNECTED == client.getConnectionState()) {
return true;
}
Log.i("Band is connecting...\n");
return ConnectionState.CONNECTED == client.connect().await();
}
示例2: getConnectedBandClient
private boolean getConnectedBandClient() throws InterruptedException, BandException {
if (client == null) {
BandInfo[] devices = BandClientManager.getInstance().getPairedBands();
if (devices.length == 0) {
appendToUI("Band isn't paired with your phone.", 1);
mTest.setTextColor(Color.parseColor("#d04545"));
return false;
}
client = BandClientManager.getInstance().create(getBaseContext(), devices[0]);
} else if (ConnectionState.CONNECTED == client.getConnectionState()) {
return true;
} else if(ConnectionState.UNBOUND == client.getConnectionState())
return false;
appendToUI("Band is connecting...", 1);
return ConnectionState.CONNECTED == client.connect().await();
}
示例3: getConnectedBandClient
/**
* 连接band
*/
private boolean getConnectedBandClient() throws InterruptedException, BandException {
if (client == null) {
BandInfo[] devices = BandClientManager.getInstance().getPairedBands();
if (devices.length == 0) {
appendToUI("Band isn't paired with your phone.\n");
return false;
}
client = BandClientManager.getInstance().create(getBaseContext(), devices[0]);
} else if (ConnectionState.CONNECTED == client.getConnectionState()) {
return true;
}
//appendToUI("Band is connecting...\n");
return ConnectionState.CONNECTED == client.connect().await();
}
示例4: getConnectedBandClient
/**
* 连接band
*/
private boolean getConnectedBandClient() throws InterruptedException, BandException {
if (client == null) {
BandInfo[] devices = BandClientManager.getInstance().getPairedBands();
if (devices.length == 0) {
Methods.showToast("Band isn't paired with your phone.\n", false);
return false;
}
client = BandClientManager.getInstance().create(getBaseContext(), devices[0]);
BandApplication.client = client;
} else if (ConnectionState.CONNECTED == client.getConnectionState()) {
return true;
}
Methods.showToast("Band is connecting...\n", false);
return ConnectionState.CONNECTED == client.connect().await();
}
示例5: getConnectedBandClient
/**
* get the Microsoft band client, that handles all the connections and does the actual measurement
* @return wether the band is connected
* @throws InterruptedException connection has dropped e.g.
* @throws BandException ohter stuff that should not happen
*/
boolean getConnectedBandClient() throws InterruptedException, BandException {
if (client == null) {
BandInfo[] devices = BandClientManager.getInstance().getPairedBands();
if (devices.length == 0) {
notifyDeviceError(activity.getResources().getString(R.string.error_band_not_paired));
return false;
}
client = BandClientManager.getInstance().create(activity.getApplicationContext(), devices[0]);
} else if (ConnectionState.CONNECTED == client.getConnectionState()) {
return true;
}
notifyDeviceStatusChanged(HRVDeviceStatus.CONNECTING);
return ConnectionState.CONNECTED == client.connect().await();
}
示例6: connectDevice
private boolean connectDevice() {
if (bandClient == null) return false;
Log.d(TAG, "bandClient=" + bandClient);
if (bandClient.getConnectionState() == ConnectionState.CONNECTED) return true;
try {
ConnectionState state = bandClient.connect().await();
if (ConnectionState.CONNECTED == state) {
versionFirmware = bandClient.getFirmwareVersion().await();
versionHardware = bandClient.getHardwareVersion().await();
Log.d(TAG, "versionFirmware=" + versionFirmware + " versionHardware=" + versionHardware);
if (Integer.valueOf(versionHardware) <= 19)
version = 1;
else version = 2;
}
return ConnectionState.CONNECTED == state;
} catch (Exception e) {
if(bandClient.isConnected()) return true;
Log.d(TAG, deviceId + " exception1");
Log.d(TAG, deviceId + " ...connectDataKit");
return false;
}
}
示例7: getConnectedBandClient
private boolean getConnectedBandClient() throws InterruptedException, BandException {
if (client == null) {
BandInfo[] devices = BandClientManager.getInstance().getPairedBands();
if (devices.length == 0) {
Log.e(this.getClass().getSimpleName(), "Band isn't paired with your phone.");
return false;
}
client = BandClientManager.getInstance().create(activity.getApplicationContext(), devices[0]);
} else if (ConnectionState.CONNECTED == client.getConnectionState()) {
return true;
}
Log.i(this.getClass().getSimpleName(), "Band is connecting...\n");
return ConnectionState.CONNECTED == client.connect().await();
}
示例8: getConnectedBandClient
private boolean getConnectedBandClient() throws InterruptedException, BandException {
if (client == null) {
BandInfo[] devices = BandClientManager.getInstance().getPairedBands();
if (devices.length == 0) {
appendToUI("Band isn't paired with your phone.\n");
return false;
}
client = BandClientManager.getInstance().create(getBaseContext(), devices[0]);
} else if (ConnectionState.CONNECTED == client.getConnectionState()) {
return true;
}
appendToUI("Band is connecting...\n");
return ConnectionState.CONNECTED == client.connect().await();
}
示例9: getConnectedBandClient
private boolean getConnectedBandClient() throws InterruptedException, BandException {
if (client == null) {
BandInfo[] devices = BandClientManager.getInstance().getPairedBands();
if (devices.length == 0) {
System.out.println("Band isn't paired with your phone.");
return false;
}
client = BandClientManager.getInstance().create(getBaseContext(), devices[0]);
} else if (ConnectionState.CONNECTED == client.getConnectionState()) {
return true;
}
System.out.println("Band is connecting...");
return ConnectionState.CONNECTED == client.connect().await();
}
示例10: getConnectedBandClient
private boolean getConnectedBandClient() throws InterruptedException, BandException {
if (client == null) {
BandInfo[] devices = BandClientManager.getInstance().getPairedBands();
if (devices.length == 0) {
appendToUI("Band isn't paired with your phone.\n");
return false;
}
client = BandClientManager.getInstance().create(getBaseContext(), devices[0]);
} else if (ConnectionState.CONNECTED == client.getConnectionState()) {
return true;
}
appendToUI("Band is connecting...\n");
return ConnectionState.CONNECTED == client.connect().await();
}
示例11: connect
public boolean connect() throws InterruptedException, BandException {
Log.d(TAG,"Client devices detected: "+client);
if (client == null) {
BandInfo[] devices = BandClientManager.getInstance().getPairedBands();
Log.d(TAG,"Devices: "+devices);
Log.d(TAG,"Band devices detected: "+devices.length);
if (devices == null) {
return false;
}
client = BandClientManager.getInstance().create(mainActivity.getApplicationContext(), devices[0]);
Log.d(TAG,"Client devices detected: "+client);
Log.d(TAG,"Client devices detected: "+client.getConnectionState().toString());
} else if (ConnectionState.CONNECTED == client.getConnectionState()) {
return true;
}
client.registerConnectionCallback(new BandConnectionCallback() {
@Override
public void onStateChanged(ConnectionState connectionState) {
Log.i(TAG,"Connection status change to: "+connectionState.toString());
logViewer.addMessage("Band connected: "+ connectionState.toString());
Log.i(TAG,"2 Connection status change to: "+connectionState.toString());
mainActivity.updateBandStatus(connectionState.toString());
Log.i(TAG,"3 Connection status change to: "+connectionState.toString());
}
});
boolean out = ConnectionState.CONNECTED == client.connect().await();
Log.d(TAG,"Output of the connect method: "+out);
return out;
}
示例12: onStateChanged
@Override
public void onStateChanged(ConnectionState connectionState)
{
connected = (connectionState == ConnectionState.CONNECTED);
Log.i("MSBand connection status: " + connectionState.toString());
}