欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
關于android APP 與 藍牙連接的問題
[打印本頁]
作者:
qq1105424012
時間:
2017-12-25 15:27
標題:
關于android APP 與 藍牙連接的問題
//
藍牙設備連接程序
private class
BluetoothConnect
extends
Thread
{
private
BluetoothSocket
tempSocket
;
private
BluetoothDevice
tempDevice
;
public
BluetoothConnect
(
BluetoothDevice
device
)
{
BluetoothSocket
temp
=
null
;
tempDevice
=
device
;
//
以下程序用于獲取
BluetoothSocket
try
{
temp
=
tempDevice
.
createRfcommSocketToServiceRecord
(
UUID
.
fromString
(
BluetoothCOM_UUID
))
;
Toast
.
makeText
(
getApplication
()
,
device
.
getAddress
()
,
Toast
.
LENGTH_LONG
)
.
show
()
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
()
;
}
tempSocket
=
temp
;
}
public void
run
()
{
myBluetoothAdapter
.
cancelDiscovery
()
;
//
以下程序用于連接藍牙設備
try
{
tempSocket
.
connect
()
;
// MainActivity.myBluetoothSocket=x;//
此處注意
Message
msg
=
new
Message
()
;
msg
.
arg1
=
1
;
handler
.
sendMessage
(
msg
)
;
}
catch
(
IOException
e
)
{
try
{
tempSocket
.
close
()
;
Message
msg
=
new
Message
()
;
msg
.
arg1
=
2
;
handler
.
sendMessage
(
msg
)
;
}
catch
(
IOException
ee
)
{
}
return
;
}
}
連接原理,到底是怎么回事?
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1