gpt4 book ai didi

android - listenUsingRfcommWithServiceRecord(字符串名称,UUID uuid)不工作

转载 作者:行者123 更新时间:2023-11-29 21:54:08 24 4
gpt4 key购买 nike

所以我试图让这段代码运行起来

public AcceptThread() {
// Use a temporary object that is later assigned to mmServerSocket,
// because mmServerSocket is final
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
BluetoothServerSocket tmp = null;
try {
// MY_UUID is the app's UUID string, also used by the client code
tmp = mBluetoothAdapter.listenUsingRfcommWithServiceRecord("Server", MY_UUID);
} catch (IOException e) { }
mmServerSocket = tmp;
}

但是当我从应该分配 tmp 的行继续时,它仍然是空的。蓝牙已激活,但当我连接到它时,它不会将 tmp 设置为任何东西。有什么想法为什么不呢?顺便说一句。这种方法在 2.2 android 机器上不起作用吗,因为它在我的 2.2 机器上的那一行崩溃了,但在我的 4.1.2 设备上却没有。

如果需要任何更多信息才能回答,请提出要求,我会尽我所能提供。

最佳答案

发现我没有允许应用程序使用蓝牙,所以解决了。

关于android - listenUsingRfcommWithServiceRecord(字符串名称,UUID uuid)不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13693916/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com