when i close the application from main activity i have the following question regarding the simplified code below.
1) do i need to close the asyncstream specifically when i stop the logger service?
i've read you should not reuse an asyncstream. however, since it is in the starter service (and assuming the starter service hasn't been killed) can i just initialize it again as shown?
1) do i need to close the asyncstream specifically when i stop the logger service?
i've read you should not reuse an asyncstream. however, since it is in the starter service (and assuming the starter service hasn't been killed) can i just initialize it again as shown?
B4X:
[starter service]
Sub Process_Globals
Public usb As UsbSerial
Public AStreamUsb As AsyncStreams
End Sub
[main activity]
sub startlogging
starter.usb.open(9600,1)
startservice(logger)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
'clean up some stuff
StopService(BTLogger)
Activity.Finish
End If
End Sub
[logger service]
Sub Service_Create
Starter.AStreamUsb.Initialize(Starter.usb.GetInputStream,Starter.usb.GetOutputStream,"astreamusb")
Service.StartForeground(1,notes)
End Sub
Sub Service_Destroy
Starter.usb.Close
'????? Starter.AStreamUsb.Close
End Sub
Sub astreamusb_Error
Starter.AStreamUsb.Close
End Sub
Sub astreamusb_Terminated
Starter.AStreamUsb.Close
End Sub
Last edited: