本文整理汇总了Java中android.bluetooth.BluetoothDevice.getType方法的典型用法代码示例。如果您正苦于以下问题:Java BluetoothDevice.getType方法的具体用法?Java BluetoothDevice.getType怎么用?Java BluetoothDevice.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.bluetooth.BluetoothDevice
的用法示例。
在下文中一共展示了BluetoothDevice.getType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bind
import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
@Override public void bind(BluetoothDevice device) {
nameView.setText(device.getName());
switch (device.getType()) {
case DEVICE_TYPE_CLASSIC:
typeView.setText("DEVICE_TYPE_CLASSIC");
break;
case DEVICE_TYPE_DUAL:
typeView.setText("DEVICE_TYPE_DUAL");
break;
case DEVICE_TYPE_LE:
typeView.setText("DEVICE_TYPE_LE");
break;
case DEVICE_TYPE_UNKNOWN:
typeView.setText("DEVICE_TYPE_UNKNOWN");
break;
default:
typeView.setText("What's this?");
break;
}
addressView.setText(device.getAddress());
ParcelUuid[] uuids = device.getUuids();
uuidView.setText(Arrays.toString(uuids));
}
示例2: connect
import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
@Override
public synchronized void connect(String address) {
if (mBluetoothAdapter == null || address == null) {
NLog.w("BluetoothAdapter not initialized or unspecified address.");
this.responseMsg(new PenMsg(PenMsgType.PEN_CONNECTION_FAILURE));
return;
}
if (penAddress != null)
{
if (this.penStatus == CONN_STATUS_AUTHORIZED)
{
responseMsg(new PenMsg(PenMsgType.PEN_ALREADY_CONNECTED));
return;
}
else if (this.penStatus != CONN_STATUS_IDLE)
{
return;
}
}
final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
if (device == null) {
NLog.w("Device not found. Unable to connect.");
this.responseMsg( new PenMsg( PenMsgType.PEN_CONNECTION_FAILURE ) );
return;
}
if ( device.getType() != BluetoothDevice.DEVICE_TYPE_LE )
{
NLog.w("MacAddress is not Bluetooth LE Type");
this.responseMsg( new PenMsg( PenMsgType.PEN_CONNECTION_FAILURE ) );
return;
}
if ( this.penStatus != CONN_STATUS_IDLE ) {
responseMsg(new PenMsg(PenMsgType.PEN_CONNECTION_FAILURE));
return;
}
this.penAddress = address;
onConnectionTry();
responseMsg(new PenMsg(PenMsgType.PEN_CONNECTION_TRY));
this.penBtName = device.getName();
this.watchDog = new Timer();
this.watchDogTask = new TimerTask() {
@Override
public void run() {
watchDogAlreadyCalled = true;
NLog.d("Run WatchDot : connect failed");
responseMsg( new PenMsg( PenMsgType.PEN_CONNECTION_FAILURE) );
onDisconnected();
close();
}
};
this.watchDogAlreadyCalled = false;
this.mBluetoothGatt = device.connectGatt(context, false, mBluetoothGattCallback);
try {
// schedule이 시작전에 connectGatt가 불려서 Cancel이 되어버리는 경우에 대한 exception처리
// 커넥션 이후엔 여기에 문제가 생겨도 지장없음.
this.watchDog.schedule(watchDogTask, 3000); // 3초
}
catch (Exception e)
{
e.printStackTrace();
}
NLog.d("Trying to create a new connection.");
}
示例3: onLeScan
import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
@Override
public void onLeScan(final BluetoothDevice device, int i, byte[] bytes) {
if (device.getType() == BluetoothDevice.DEVICE_TYPE_LE) {
onFind(device);
}
}
示例4: BLEMeasurementsRecord
import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public BLEMeasurementsRecord(List<ScanResult> scanResults) {
super(new RecordInfo());
this.deviceCount = scanResults.size();
this.deviceAddresses = new String[deviceCount];
this.deviceNames = new String[deviceCount];
this.rssis = new int[deviceCount];
this.deviceBondStatuses = new int[deviceCount];
this.deviceTypes = new int[deviceCount];
this.timestampsNano = new long[deviceCount];
this.advertisingSids = new int[deviceCount];
this.dataStatuses = new int[deviceCount];
this.periodicAdvertisingIntervals = new int[deviceCount];
this.primaryPhies = new int[deviceCount];
this.secondaryPhies = new int[deviceCount];
this.txPowers = new int[deviceCount];
this.areConnectable = new boolean[deviceCount];
this.areLegacy = new boolean[deviceCount];
this.uuids = new String[deviceCount];
this.majors = new int[deviceCount];
this.minors = new int[deviceCount];
for (int i = 0; i < scanResults.size(); i++) {
ScanResult scanResult = scanResults.get(i);
BluetoothDevice bluetoothDevice = scanResult.getDevice();
this.deviceAddresses[i] = nullStringToEmpty(bluetoothDevice.getAddress());
this.deviceNames[i] = nullStringToEmpty(bluetoothDevice.getName());
this.rssis[i] = scanResult.getRssi();
this.deviceBondStatuses[i] = bluetoothDevice.getBondState();
this.deviceTypes[i] = bluetoothDevice.getType();
this.timestampsNano[i] = scanResult.getTimestampNanos();
this.advertisingSids[i] = getAdvertisingSid(scanResult);
this.dataStatuses[i] = getDataStatus(scanResult);
this.periodicAdvertisingIntervals[i] = getPeriodicAdvertisingInterval(scanResult);
this.primaryPhies[i] = getPrimaryPhy(scanResult);
this.secondaryPhies[i] = getSecondaryPhy(scanResult);
this.txPowers[i] = getTxPower(scanResult);
this.areConnectable[i] = getIsConnectable(scanResult);
this.areLegacy[i] = getIsLegacy(scanResult);
byte[] scanRecord = scanResult.getScanRecord().getBytes();
this.uuids[i] = getUuid(scanRecord);
this.majors[i] = getMajor(scanRecord);
this.minors[i] = getMinor(scanRecord);
}
}