Getting the name of a wear-resistant device

I would like to get the name of the connected wear device like “Gear Live 02xx”.

Can I use the wear API to achieve this?

Using this:

node.getDisplayName(); 

I get the line as 4750237895-4553-4343-xxxxxxxxxxxxx.

+5
source share
4 answers

There is no official API to get the name of the bootable device that appears when the watch first loads, for example, G WATCH 1234 or MOTO 360 1234.

This may change in the future, but if you want to get a similar name right now, you need to do something like this:

  BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); String btAddress = "No Bluetooth"; if (btAdapter != null) btAddress = btAdapter.getAddress(); // Reconstitute the pairing device name from the model and the last 4 digits of the bluetooth MAC String wearName; if ((btAddress != null) && (!btAddress.equals("No Bluetooth"))) { wearName = android.os.Build.MODEL; String[] tokens = btAddress.split(":"); wearName += " " + tokens[4] + tokens[5]; wearName = wearName.toUpperCase(); } else { wearName = "No Bluetooth"; } 
+3
source

Why not use bluetooth api? http://developer.android.com/guide/topics/connectivity/bluetooth.html#QueryingPairedDevices

API description is not so clear: human-readable description of node. Sometimes a bluetooth device name is created

"Sometimes" doesn’t explain so well ... the Hex2ASCII string conversion looks like this:

GP # xESCC and too far from behalf of Gear Live ...

I used this to convert: http://www.rapidtables.com/convert/number/hex-to-ascii.htm

+4
source

You can use Build.MODEL and Build.BRAND (from Wear side).

With the LG G Watch, it will return you the “G Watch” and “lge,” respectively. If you want to get it from a handheld computer, I think you (should) know how to communicate between both parties.

+3
source

You do not know what “02xx” is in your question, but for the model of the wear device to use the value Build.MODEL. See http://developer.android.com/reference/android/os/Build.html

This will need to be done on the wear device and shared with your mobile application through the Message framework: https://developer.android.com/training/wearables/data-layer/messages.html

+1
source

Source: https://habr.com/ru/post/1204806/


All Articles