Không có API chính thức để lấy tên của thiết bị đeo được được hiển thị khi đồng hồ bị khởi động đầu tiên, chẳng hạn như G XEM 1234 hoặc MOTO 360 1234.
này có thể thay đổi trong tương lai, nhưng nếu bạn muốn có tên tương tự ngay bây giờ, bạn cần phải làm một việc như sau:
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";
}
Nguồn
2014-10-17 03:55:43
Vui mừng khi biết kết quả sẽ là gì? nếu chúng tôi đang sử dụng Ứng dụng xem trước Android Wear! –