gpt4 book ai didi

Android 蓝牙为 BluetoothSocket.connect() 设置超时;

转载 作者:行者123 更新时间:2023-11-29 01:32:19 24 4
gpt4 key购买 nike

是否有机会为

设置超时
BluetoothSocket.connect();

以便该方法在一定时间后取消?

谢谢!

最佳答案

如果你想在设备在一定时间内没有连接时取消连接尝试,那么运行一个线程。

runOnUiThread(new Runnable() {
@Override
public void run() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 5 second
}
}, 5000);
}
});

关于Android 蓝牙为 BluetoothSocket.connect() 设置超时;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30486753/

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