Android Question No more AsynchStreams

lsis

Member
Licensed User
Longtime User
Any other way to read inputstream and write outputstream with a buffer except AsyncStreams?
I read that AsynchStreams not fires new data event in a service with phone on sleep mode.
Another one is that i want to read AsynchStreams new data buffer in a thread, but i think something goes wrong.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I read that AsynchStreams not fires new data event in a service with phone on sleep mode.
This is not related to AsyncStreams. Android pauses all apps when the phone is sleeping. You can use PhoneWakeState to acquire a partial lock to prevent the device from sleeping.

Another one is that i want to read AsynchStreams new data buffer in a thread, but i think something goes wrong.
You don't need to add additional thread. This is exactly the purpose of AsyncStreams. It handles the communication with two background threads.
 
Upvote 0

lsis

Member
Licensed User
Longtime User
I need a continiue serial read write loop and polling.
This is a too bad for a big application with one thread i think.
Another one is that we have to change source code from other platforms where we know the good working state.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
need a continiue serial read write loop and polling.
This is a too bad for a big application with one thread i think.
But this is exactly the point behind AsyncStreams. It reads and writes the data in the background without affecting the main thread.

BTW, you don't need to use AsyncStreams if you don't like. You can use InputStream / OutputStream directly (maybe with a timer).
You need to set androidSdkVersion to 4 or otherwise you will get a NetworkOnMainThread exception.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…