Android Question Recognize new data with ASTREAM in service

petr4ppc

Well-Known Member
Licensed User
Longtime User
Dear friends, please,

I have not found on forum some advice, how to solve this situation:
I am using (in main) ASTREAM for reading the BT seriál port,
but if my app is in PAUSE mode, then I can not manage the routine astream - my app is silent.
Then I resume my APP and - I can read data on BT seriál again....


It is standard question here I know
"How to read data on seriál port with ASTREAM in service?" Is here some best advice for this? Where I must begin, please?

Thank you very much
p4ppc
 

petr4ppc

Well-Known Member
Licensed User
Longtime User
Dear Erel, thank you for your answer.

I am using services and I can use CallSubDelayed.
But for receiving data via BT seriál port in service:
I dont know for example if I must write something (API) to Manifest editor.....

For example for checking BT aktivity I have in manifest this:
B4X:
AddReceiverText(myservice, <intent-filter>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED"/>
</intent-filter>)
AddPermission(android.permission.BLUETOOTH)

what I must write similar in manifest editor for checking received data via seriál port, please?

And you wrote:
Move all the communication code to a service.

If I put Sub AStream_NewData (Buffer() AsByte) in service and I delete this sub in (main) then after receiving data via BT seriál port I get error:

Astream_newdata was not found

I have deleted it from main but in service I have this



Thank you very much
p4ppc
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You don't need to add anything to the manifest file in order to communicate with a Bluetooth device. The snippet you posted is not related to any activity and is not required.

If I put Sub AStream_NewData (Buffer() AsByte) in service and I delete this sub in (main) then after receiving data via BT seriál port I get error:
You should move AStream and all the other code to the service as well.
 
Upvote 0
Top