2014-04-18 35 views
0

我有一個Android「伴侶」應用程序,該應用程序在Glass上連接的手機上運行,​​並與在Glass上運行的GDK應用程序交談。我正在尋找的是一種確定(從手機端以編程方式)給定的藍牙配對是否適用於Glass的方法。檢測玻璃與手機配對

我唯一想到的是檢查設備名稱是否包含單詞「Glass」 - 因爲AFAIK是Glass指定的默認設備名稱,並且沒有我知道的UI改變它。但這非常有趣。任何更好的想法?

回答

0

我想你可以從BluetoothAdapter.getDefaultAdapter()。getBondedDevices()遍歷服務uuid​​s列表,然後檢查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. 

    } 
} 
+0

在我的設備更新到16.1之前,我沒有機會在XE16上進行測試,但它在那裏不工作。我的玻璃有5個UIUD,其中沒有一個是在這裏檢查的。 – String