Thursday, 15 September 2011

java - Set/Get UUID on Android Device -


I am sitting on this problem for a few weeks, sometimes it works randomly, but I understand it How to get it to work on different devices.

I want to connect an Android (phone) app to another (Google Glass) via Bluetooth. That's why I'm calling "listenUsingRfcommWithServiceRecord" on my glass device as far as I think it will add the specified UUID to its glass's SPD service. I do not know what the string name parameter does, to be honest, so I just put my app-name. This code is used on Glass:

  Public BtServer () {btAdapter = BluetoothAdapter.getDefaultAdapter (); BluetoothServerSocket tmp = null; Try {Tmp = btAdapter.listenUsingRfcommWithServiceRecord ("Phone", MY_UUID); } Hold (Last IOException E) {// TODO Auto generated Holding Block e.printStackTrace (); } BtServerSocket = tmp; }  

When I get the UUID of my glass device on my phone and display them, the UUID shows only for any reason in a single device. This code is the output output:

  / ** * Get the equipment of coupled glass * Returns of wireless specs * / private set & lt ; Bluetooth devices & gt; GetPairedGlass () {last set & lt; Bluetooth devices & gt; Coupled Devices = BTset.JetPower Devices (); // (Last BluetoothDevice e: pairedDevices) returns returns to all the bonded devices if (e.fetchUuidsWithSdp ()) {Last ParcelUuid [] uuids = e.getUuids (); (Last parallel UID B: UIDs) System.out.printLN ("+ + + e.getName (+) +": "+ b.getUuid (.) ToString ()); } Returning Devices; }  

Output:

  03-17 14: 54: 29.812: I / System.out (17149): xxx's glass: 0000111e-0000 -1000 -8000-00805f9b34fb 03-17 14: 54: 29.812: I / System. Out (17149): Glass of xxx: 00001115-0000-1000-8000-00805f9b34fb 03-17 14: 54: 29.812: I / System.out (1714 9)): xxx Glass: 00001133-0000-1000-8000 -00805f9b34fb 03-17 14: 54: 29.822: I / System.out (17149): xxx Glass: f96647cf-7f25-4277-843d-f407b4192f8b 03-17 14:54: 29.822: I / System.out (17149) Glass of xxx: f15cc914-e4bc-45ce-9930-cb7695385850 03-17 14: 54: 29.822: I / System.out (17149): xxx Glass: ab390c1b-9a5b-4104-932d-cce5e542b5c6 03-17 14: 54: 29.822: I / System.out (17149): xxx Glass: ab390c1b-9a5b-4104-932d-cce5e542b5c6 03-17 14: 54: 29.822: I / System.out (17149): xxx Glass: 5e8945b0- 9525-11e3-a5e2-0800200c9a66 03-17 14: 54: 29.832: I / System.out (17149): Test Account Gloss: 0000111e-0000-1000-8000-00805f9b34fb 03-17 14: 54: 29.832: I / Sist . Out (17149): Test Accounts Glass: 00001115-0000-1000-8000-00805f9b34fb 03-17 14: 54: 29.832: I / System. UT (17149): Test Account Gloss: 00001133-0000-1000- 8000-00805f9b34fb 03-17 14: 54: 29.832: I / System.out (17149): Test Account Gloss: f96647cf-7f25-4277-843d-f407b4192f8b 03 -17 14: 54: 29.832: I / System. Out (1714 9): Test Accounts Gloss: 5e8945b0-9525-11e3- A5A20000200c 9a66 03-17 14: 54: 29.832: I / System. Out (17149): Test Account Gloss:. F15cc914-e4bc-45ce-9930-cb7695385850  

UUID is specified in both applications "ab390c1b-9a5b-4104-932d-cce5e542b5c6"

This works my xxx Just fine on the glass, but I can not get it to work on my test account glass. I do not understand why fetchUuidsWithSdp for my xxx device, because it is not currently connected with my phone, returns right so these exclusions are probably just local copies.

On the phone, I get an IOAction while calling "Make Sure Restore Socket Service Service (UUID)", because there is no service with that UUID on my glass. When trying a different UUID, it does not work either.

How do I set up UUID for my app on my device? Or am I doing a wrong UUID and actually setting up? If someone knows how to do it then I would be very grateful.


No comments:

Post a Comment