本文整理汇总了Java中javax.bluetooth.DiscoveryListener.deviceDiscovered方法的典型用法代码示例。如果您正苦于以下问题:Java DiscoveryListener.deviceDiscovered方法的具体用法?Java DiscoveryListener.deviceDiscovered怎么用?Java DiscoveryListener.deviceDiscovered使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.bluetooth.DiscoveryListener
的用法示例。
在下文中一共展示了DiscoveryListener.deviceDiscovered方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runDeviceInquiry
import javax.bluetooth.DiscoveryListener; //导入方法依赖的package包/类
public int runDeviceInquiry(DeviceInquiryThread startedNotify, int accessCode, DiscoveryListener listener)
throws BluetoothStateException {
try {
int discType = runDeviceInquiryImpl(startedNotify, accessCode, listener);
if (discType == DiscoveryListener.INQUIRY_COMPLETED) {
// Report found devices if any not reported
Hashtable previouslyFound = (Hashtable) deviceDiscoveryListenerFoundDevices.get(listener);
if (previouslyFound != null) {
Vector reported = (Vector) deviceDiscoveryListenerReportedDevices.get(listener);
for (Enumeration en = previouslyFound.keys(); en.hasMoreElements();) {
RemoteDevice remoteDevice = (RemoteDevice) en.nextElement();
if (reported.contains(remoteDevice)) {
continue;
}
reported.addElement(remoteDevice);
Integer deviceClassInt = (Integer) previouslyFound.get(remoteDevice);
DeviceClass deviceClass = new DeviceClass(deviceClassInt.intValue());
listener.deviceDiscovered(remoteDevice, deviceClass);
// If cancelInquiry has been called
if (!deviceDiscoveryListeners.contains(listener)) {
return DiscoveryListener.INQUIRY_TERMINATED;
}
}
}
}
return discType;
} finally {
deviceDiscoveryListeners.removeElement(listener);
deviceDiscoveryListenerFoundDevices.remove(listener);
deviceDiscoveryListenerReportedDevices.remove(listener);
}
}
示例2: deviceDiscoveredCallback
import javax.bluetooth.DiscoveryListener; //导入方法依赖的package包/类
public void deviceDiscoveredCallback(DiscoveryListener listener, long deviceAddr, int deviceClass,
String deviceName, boolean paired) {
// Copied directly from WIDCOMM driver
DebugLog.debug("deviceDiscoveredCallback deviceName", deviceName);
if (!deviceDiscoveryListeners.contains(listener)) {
return;
}
// Update name if name retrieved
RemoteDevice remoteDevice = RemoteDeviceHelper.createRemoteDevice(this, deviceAddr, deviceName, paired);
Vector reported = (Vector) deviceDiscoveryListenerReportedDevices.get(listener);
if (reported == null || (reported.contains(remoteDevice))) {
return;
}
// See -Dbluecove.inquiry.report_asap=false
Hashtable previouslyFound = (Hashtable) deviceDiscoveryListenerFoundDevices.get(listener);
if (previouslyFound != null) {
Integer deviceClassInt = (Integer) previouslyFound.get(remoteDevice);
if (deviceClassInt == null) {
previouslyFound.put(remoteDevice, new Integer(deviceClass));
} else if (deviceClass != 0) {
previouslyFound.put(remoteDevice, new Integer(deviceClass));
}
} else {
DeviceClass cod = new DeviceClass(deviceClass);
reported.addElement(remoteDevice);
DebugLog.debug("deviceDiscoveredCallback address", remoteDevice.getBluetoothAddress());
DebugLog.debug("deviceDiscoveredCallback deviceClass", cod);
listener.deviceDiscovered(remoteDevice, cod);
}
}
示例3: deviceDiscoveredCallback
import javax.bluetooth.DiscoveryListener; //导入方法依赖的package包/类
public void deviceDiscoveredCallback(DiscoveryListener listener, long deviceAddr, int deviceClass,
String deviceName, boolean paired) {
DebugLog.debug("deviceDiscoveredCallback", deviceName);
RemoteDevice remoteDevice = RemoteDeviceHelper.createRemoteDevice(this, deviceAddr, deviceName, paired);
if ((currentDeviceDiscoveryListener == null) || (currentDeviceDiscoveryListener != listener)) {
return;
}
listener.deviceDiscovered(remoteDevice, new DeviceClass(deviceClass));
}