【问题标题】:How could I get the bluetooth UUIDs of my own android device?我怎样才能获得我自己的 android 设备的蓝牙 UUID?
【发布时间】:2012-12-16 22:36:29
【问题描述】:

我目前可以fetchUuidsWithSdp 使用远程设备。 getUuids 不起作用,不知道为什么)

但是我怎样才能获得我自己的 android 设备的 UUID?

假设当我在 服务器套接字上成功执行 accept() 时,注册的 UUID必须包括我在使用此命令创建服务器套接字listenUsingInsecureRfcommWithServiceRecord

我发现并非总是如此!我想测试一下..

【问题讨论】:

  • 你得到答案了吗,我也在寻找我自己设备的 UUID。

标签: android bluetooth uuid sdp


【解决方案1】:

嘿,有点晚了,但我发现最好的方法是做这样的事情。对于生产代码,我不是最好的想法,但对于测试它还不错。

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); 
Method getUUIDsMethod = BluetoothAdapter.class.getDeclaredMethod("getUuids", null);
ParcelUuid[] dUUIDs = (ParcelUuid[]) getUUIDsMethod.invoke(mBluetoothAdapter, null);

希望对你有帮助

【讨论】:

    【解决方案2】:
     TelephonyManager tManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
     String uuid = tManager.getDeviceId();
    //or
    UUID.nameUUIDFromBytes(tManager.getDeviceId().getBytes("utf8"))
    

    【讨论】:

    • 这个问题与蓝牙有关,而不是电话:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-24
    • 1970-01-01
    • 2017-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多