Android Question Result in Debug Mode OK but Release Mode Not

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

I have an app which reads the temperature from a remote device. An external library is used and accessed via JavaObjects. In Debug Mode the temperature is returned correctly, but in Release Mode the value returned is 0, which is the initial value. When running the same app in B4J all works fine.

I found out that an error is returned "android.os.NetworkOnMainThreadException". So it seems that there is a thread conflict.

Has someone an example on how to handle multiple threads, in this case submit request to the remote device and capture the result.

Appreciated
 

DonManfred

Expert
Licensed User
Longtime User
How do you sending and recieving the requests to the remote device?
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
How do you sending and recieving the requests to the remote device?
Hi Manfred,

by using the external library methods like connect > read the temp > disconnect. These are executed sequentielly in one sub which returns the temperature.
BTW: These methods are based on the TinkerForge.jar - and as mentioned working fine in B4J.
Googling some threads around the "android.os.NetworkOnMainThreadException", it is adviced to setup a AsyncTask - but not clear on how to do that in B4A.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi All,

using DisableStrictMode prior calling the sub works.

Note: Great to see that the classes developed for B4J can be used in B4A.

Thanks a Lot for your help and a Happy Christmas,
Rob
 
Upvote 0
Top