ブルーコーブを使用して、デバイスを永久に照会モードにすることができるかどうかを知りたいです。
実際のコードは次のとおりです。デバイスを短時間だけ照会します。
public class DescobrirDispositivos {
/**
* @param args
* @throws BluetoothStateException
* @throws InterruptedException
*/
public static final Vector/*<RemoteDevice>*/ devicesDiscovered = new Vector();
public static void main(String[] args) throws BluetoothStateException,
InterruptedException {
final Object inquiryCompletedEvent = new Object();
DiscoveryListener listener = new DiscoveryListener() {
@Override
public void servicesDiscovered(int arg0, ServiceRecord[] arg1) {
// TODO Auto-generated method stub
}
@Override
public void serviceSearchCompleted(int arg0, int arg1) {
// TODO Auto-generated method stub
}
@Override
public void inquiryCompleted(int discType) {
synchronized (inquiryCompletedEvent) {
inquiryCompletedEvent.notifyAll();
}
}
@Override
public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {
devicesDiscovered.addElement(btDevice);
System.out.println("Device " + btDevice.getBluetoothAddress()
+ " found");
try {
System.out.println("Name " + btDevice.getFriendlyName(false));
} catch (IOException cantGetDeviceName) {
// TODO Auto-generated catch block
}
}
};
synchronized (inquiryCompletedEvent) {
boolean started = LocalDevice.getLocalDevice().getDiscoveryAgent()
.startInquiry(DiscoveryAgent.GIAC, listener);
if (started) {
inquiryCompletedEvent.wait();
}
}
}
}