简体   繁体   English

检测玻璃与手机配对

[英]Detect Glass paired with phone

I have an Android "companion" app which runs on the phone to which Glass is tethered, and talks to a GDK app running on Glass. 我有一个Android“伴侣”应用程序,该应用程序在与Glass绑定的电话上运行,并与在Glass上运行的GDK应用程序对话。 What I'm looking for is a way to determine (programmatically, from the phone side) if a given Bluetooth pairing is to Glass or not. 我正在寻找一种方法(从电话端以编程方式确定),确定给定的蓝牙配对是否与Glass配对。

The only thing I've come up with is to check if the device name includes the word "Glass" - since, AFAIK, the default device name that Glass assigns itself always does, and there's no UI that I know of to change it. 我想出的唯一一件事就是检查设备名称是否包含单词“ Glass”-因为AFAIK始终是Glass为其分配的默认设备名称,并且我不知道要更改它的UI。 But that's pretty hokey. 但这真是曲调。 Any better ideas? 还有更好的主意吗?

I think you can iterate over the list of service uuids from BluetoothAdapter.getDefaultAdapter().getBondedDevices() and then check for the Glass uuid. 我认为您可以从BluetoothAdapter.getDefaultAdapter()。getBondedDevices()遍历服务uuid​​的列表,然后检查Glass uuid。

Set<BluetoothDevice> devices = BluetoothAdapter.getDefaultAdapter().getBondedDevices();
BluetoothDevice glass = null;
for (BluetoothDevice d : devices {
    ParcelUuid[] uuids = d.getUuids();
        for (ParcelUuid p : uuids) {
           System.out.println(p.getUuid().toString());
           if (p.getUuid().toString().equals("fafbdd20-83f0-4389-addf-917ac9dae5b1")) {
                  //found in the GlassHome.apk for XE16.  
                 glass = d;
                 break;
           }
          //NOTE: you may need to adjust this UIUD.
        }
     if (glass != null) { break; }
}
if (glass != null) {
   if (glass.getBondState().equals(BOND_BONDED) {
      //This last check makes sure you are through the pairing process.

   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM