Android Tutorial Android Bluetooth / BluetoothAdmin Tutorial

Status
Not open for further replies.

Computersmith64

Well-Known Member
Licensed User
Longtime User
You should make sure that BluetoothAdmin is initialized exactly once and is a process global variable.
I'm pretty sure that's what I'm doing. I'm doing it in a service & admin is declared in Process_Globals & initialized in Service_Create. Once the transfer is complete, I stop the service then start it again if necessary. Would that count as initializing admin more than once, or is it OK because the variable is destroyed when the service is stopped?

- Colin.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm doing it in a service & admin is declared in Process_Globals & initialized in Service_Create
This is the problem. Process global variables are not destroyed when the service is destroyed. Check whether the object IsInitialized before you initialize it.

I recommend you to avoid stopping the service. It will do no good and will only complicate things.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
OK, thanks - I'll try that. I was stopping the service because I thought it would be good practice to clean it up if it's not being used.

- Colin.
 

red30

Well-Known Member
Licensed User
Longtime User
B4X:
Dim MyMac(50) As String   
Dim U=0,m=0 As Int
Sub Admin_DeviceFound (Name As String, MacAddress As String)
    Log(Name & ":" & MacAddress)
    Dim nm As NameAndMac
    nm.Name = Name
    nm.Mac = MacAddress
        If m=0 Then
            foundDevices.Add(nm)
            ProgressDialogShow("Searching for devices (~ device founded)".Replace("~", foundDevices.Size))
            MyMac(0)=MacAddress
            m=m+1
        Else
            For i=0 To m-1
                U=0
                If MyMac(i)=MacAddress Then Exit
                U=1
            Next
            If U=1 Then
                foundDevices.Add(nm)
                ProgressDialogShow("Searching for devices (~ device founded)".Replace("~", foundDevices.Size))
                MyMac(m)=MacAddress
                m=m+1
            End If
        End If
End Sub
Corrects the multiple search error of the same device.
 

krokiz

Member
Licensed User
Longtime User
Million times "THANK YOU" for putting this information on Page 1:

"AddPermission(android.permission.ACCESS_COARSE_LOCATION)"

I was struggling for months to make my application to work on Android versions higher than 4.4.2 !

!!!!!!!!!1
 

Gianluca Esposito

Member
Licensed User
Longtime User
hi,
How do I send the following command?

Command sent:
0x8001 (Fixed)
0x0000 (Message ID)
0x00005358 (Vendor ID = CAEN SpA)
0x0021 (Message Length)
0x0000 (Reserved)
0x0008 (AVP Length)
0x0001 (AVP Type = CommandName)
0x0013 (AVP Value = InventoryTag)
0x0000 (Reserved)
0x000F (AVP Length)
0x00FB (AVP Type = SourceName)
0x536F757263655F3000 (AVP Value = “Source_0”)

Thanks
 

Beja

Expert
Licensed User
Longtime User
The tutorial and example in the first post was rewritten.

It is implemented in a more robust way and the targetSdkVersion is set to 26.

Great update.. Thanks.
worth mentioning that the new version requires B4A 8+
 

Beja

Expert
Licensed User
Longtime User
Done!.. working like a charm, very fast.. you only need to have something to say
 

amidgeha

Active Member
Licensed User
Longtime User
Hi, Is it possible to use this example to send and receive OBD data?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…