Android Question serial EVENT

Arturs

Member
Licensed User
Longtime User
Hi

I am trying to manage Serial,Bluetooth,AsyncStreamsText in service module.

Bluetooth,AsyncStreamText work well but I have a problem with serial. When a connection is estabilshed the Serial_connected event is not called :(.

I do not have any ideas what I do wrongly.

B4X:
Sub serial1_Connected (Success As Boolean)

    Log("the event was called")

End Sub

Cannot the serial object work in service module ?

B4X:
Sub Service_Create
    'This is the program entry point.
    'This is a good place to load resources that are not specific to a single activity.

    admin.Initialize("admin")
    serial1.Initialize("serial1")
    foundDEvices.Initialize




End Sub



Regards
Artur
 
Last edited:

Arturs

Member
Licensed User
Longtime User
Tomarrow I spent many hours to solve my problem but without success so I decided to change some part of my code and use your solution from File Transfer (very good example)

https://www.b4x.com/android/forum/t...nd-and-receive-files-with-asyncstreams.30493/
but I have one question related to your code

In Main File you use StateChanged Event

B4X:
Sub Admin_StateChanged (NewState As Int, OldState As Int)
    UpdateUI
End Sub

but In Service Module the same Event


B4X:
Sub admin_StateChanged (NewState As Int, OldState As Int)
   If NewState = admin.STATE_ON Then serial1.Listen2("na", uuid)
End Sub

In which mode your service mode works ?

Which Event will have higher priority ?
Which will be first ?

i mean service in foregroundmode

Regards
Artur
 
Upvote 0
Top