我正在使用Raspberry pi并尝试使用bluetooth将dell pc与raspberry pi连接。我的类正在实现DiscoveryListener,它覆盖了四种方法:deviceDiscovered,inquiryCompleted,servicesDiscovered和servicesearchCompleted。 但是serviceDiscovered方法不会被执行..这是我的serviceDiscovered代码:
@Override
public void servicesDiscovered(int transID, ServiceRecord[] servRecord)
{
System.out.println("hiii");
for (int i = 0; i < servRecord.length; i++)
{
String url =
servRecord[i].getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
if (url == null)
{
continue;
}
DataElement serviceName = servRecord[i].getAttributeValue(0x0100);
if (serviceName != null)
{
System.out.println("service " + serviceName.getValue() + " found " + url);
if (serviceName.getValue().equals("OBEX Object Push"))
{
sendMessageToDevice(url);
}
}
else
{
System.out.println("service found " + url);
}
}
}
我能知道这背后的原因吗? 感谢