Android Question Variable (session) Lifetime

Discussion in 'Android Questions' started by jaraiza, Feb 24, 2015.

  1. jaraiza

    jaraiza Active Member Licensed User


    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 :)
  2. KZero

    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

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

    Dim PWS as PhoneWakeState
    False)'Don't forget to call PWS.ReleaseKeepAlive later
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice