Android Question Variable (session) Lifetime

jaraiza

Active Member
Licensed User
Hi,

I've a strange question... I made a system to sell cellphone credits via WebServices but I was asked to implement a 4 char code each time a credit is bought to avoid another person to use the system.

The system works fine, but after like 10 minutes of inactivity, the Process Variable seems to be cleared and it always fails to allow the operation.

In Main Activity (the login process) I created a variable inside Process_Globals named "wsNIP" which value is read from a WebService. In another activity (where all operation resides) the system asks for the charcode and compare it with "Main.wsNIP". As I've said, after some time it always fails.

I don't know if the ProcessGlobals are cleared because B4a, phone settings, java mood or what.

Thanks for any advice with this issue :)
 

KZero

Active Member
Licensed User
its cleared because of the Android Process lifecycle

to keep your app running in the background you will need to use "Services"
also Services will stop working when the device sleep
but its possible to prevent the device from sleeping using

B4X:
Dim PWS as PhoneWakeState
PWS.PartialLock ' this will prevent the CPU from going to sleep  Don't forget to call PWS.ReleaePartialLock later
you may also keep the screen on

B4X:
Dim PWS as PhoneWakeState
PWS.keepAlive(False)'Don't forget to call PWS.ReleaseKeepAlive later
 
Top