android读取蓝牙名称null,获取Android BluetoothDevice的重命名名称
您应该使用别名.用于设置重命名设备:try {Method method = device.getClass().getMethod("setAlias", String.class);if(method != null) {method.invoke(device, "new_device_name");}} catch (NoSuchMethodException e) {e.printSta
您应该使用别名.
用于设置重命名设备:
try {
Method method = device.getClass().getMethod("setAlias", String.class);
if(method != null) {
method.invoke(device, "new_device_name");
}
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
获取设备名称:
String deviceAlias = device.getName();
try {
Method method = device.getClass().getMethod("getAliasName");
if(method != null) {
deviceAlias = (String)method.invoke(device);
}
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
更多推荐


所有评论(0)