How to detect if bluetooth is possibe to use in device

AllyAndroid

Member
Licensed User
Longtime User
Dear friends,

I have found this:
http://www.b4x.com/forum/basic4andr...-detect-bluetooth-availability.html#post80113

but its too old mesage and it is not functioned, please, how to detect if bluetooth device is in android device?


Thank you very much,
p4ppc

The tutorial is posted here: http://www.b4x.com/forum/basic4andr...s/6908-android-serial-tutorial.html#post39900

The code you referenced still works but you would need to initialize Serial1 first.

B4X:
Dim Serial1 As Serial
Dim testSerial As String

Serial1.Initialize("Serial1")

Try
   testSerial = Serial1.Address
   Available = True
Catch
   Available = False
End Try

Edit: You also need to include the Serial library.
 
Last edited:
Upvote 0

petr4ppc

Well-Known Member
Licensed User
Longtime User
AllyAndroid

Thank you very much AllyAndroid.....it is my mistake, yes your code works

Try
testSerial = Serial1.Address
btAvailable = True
ToastMessageShow("BT is built in", True)
Catch
btAvailable = False
ToastMessageShow("BT is not built in", True)
End Try

Have a good day,
p4ppc
 
Upvote 0
Top