作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我试图让这段代码运行起来
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/
我的蓝牙服务器在尝试创建蓝牙服务器套接字时崩溃。我已经在谷歌上搜索了很多,找到了几个我尝试过的答案,但没有任何效果。我在几个不同的设备上尝试了代码,但到处都出现相同的错误。 ... private c
所以我试图让这段代码运行起来 public AcceptThread() { // Use a temporary object that is later assigned to mmSer
我是一名优秀的程序员,十分优秀!