Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android源代码中设置蓝牙设备名称?_Android_Bluetooth - Fatal编程技术网

在Android源代码中设置蓝牙设备名称?

在Android源代码中设置蓝牙设备名称?,android,bluetooth,Android,Bluetooth,我的问题与此非常相似,我需要知道如何更改BlueZ以显示实际的设备名称,即从build.prop读取,而不是显示BlueZ 我发现external/bluetooth/bluez/src/main.conf中的main.conf可能有点不正确,它包含一行关于设备名称的代码,变量设置为bluez。我尝试将其同时更改为%d和%h,但这两个选项都没有做任何更改。我将尝试手动将其设置为设备名称,但我更希望此修复可以跨多个设备使用 有什么想法吗 # Default adaper name # %h - s

我的问题与此非常相似,我需要知道如何更改BlueZ以显示实际的设备名称,即从build.prop读取,而不是显示BlueZ

我发现external/bluetooth/bluez/src/main.conf中的main.conf可能有点不正确,它包含一行关于设备名称的代码,变量设置为bluez。我尝试将其同时更改为%d和%h,但这两个选项都没有做任何更改。我将尝试手动将其设置为设备名称,但我更希望此修复可以跨多个设备使用

有什么想法吗

# Default adaper name
# %h - substituted for hostname
# %d - substituted for adapter id
Name = "Bluez"

我试着用上面两个变量来代替,但两个都没有效果。

从外部应用程序怎么样? 你可以做一个安卓版本,在最后一个状态下运行一个应用程序来更改安卓设备的名称

您可以使用IBluetooth.aidl->setName更改蓝牙名称

可以找到教程,其中包含更多参考资料

简而言之,在src中创建一个包android.bluetooth,在其中复制粘贴IBluetooth.aidl和IBluetoothCallback.aidl,您可以在前面的链接中找到它们

在代码中,导入包: 导入android.bluetooth.IBluetooth

然后执行此方法以获取Bluetooth对象:

@SuppressWarnings("rawtypes")
private IBluetooth getIBluetooth() {
    IBluetooth ibt = null;
    try {
        Class c2 = Class.forName("android.os.ServiceManager");
        Method m2 = c2.getDeclaredMethod("getService", String.class);
        IBinder b = (IBinder) m2.invoke(null, "bluetooth");
        Class c3 = Class.forName("android.bluetooth.IBluetooth");
        Class[] s2 = c3.getDeclaredClasses();
        Class c = s2[0];
        Method m = c.getDeclaredMethod("asInterface", IBinder.class);
        m.setAccessible(true);
        ibt = (IBluetooth) m.invoke(null, b);
    } catch (Exception e) {
        Log.e("flowlab", "Erroraco!!! " + e.getMessage());
    }
    return ibt;
}
然后实例化此对象: IBluetooth ib=getIBluetooth

并且可能使用
ib.setNamesomething

从外部应用程序怎么样? 你可以做一个安卓版本,在最后一个状态下运行一个应用程序来更改安卓设备的名称

您可以使用IBluetooth.aidl->setName更改蓝牙名称

可以找到教程,其中包含更多参考资料

简而言之,在src中创建一个包android.bluetooth,在其中复制粘贴IBluetooth.aidl和IBluetoothCallback.aidl,您可以在前面的链接中找到它们

在代码中,导入包: 导入android.bluetooth.IBluetooth

然后执行此方法以获取Bluetooth对象:

@SuppressWarnings("rawtypes")
private IBluetooth getIBluetooth() {
    IBluetooth ibt = null;
    try {
        Class c2 = Class.forName("android.os.ServiceManager");
        Method m2 = c2.getDeclaredMethod("getService", String.class);
        IBinder b = (IBinder) m2.invoke(null, "bluetooth");
        Class c3 = Class.forName("android.bluetooth.IBluetooth");
        Class[] s2 = c3.getDeclaredClasses();
        Class c = s2[0];
        Method m = c.getDeclaredMethod("asInterface", IBinder.class);
        m.setAccessible(true);
        ibt = (IBluetooth) m.invoke(null, b);
    } catch (Exception e) {
        Log.e("flowlab", "Erroraco!!! " + e.getMessage());
    }
    return ibt;
}
然后实例化此对象: IBluetooth ib=getIBluetooth

并且可能使用 ib.setNamesomething