Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Android Functionality differs with Build

I implemented functionality for the my app to logout when the home or back button is pressed. I also implemented a handler to logout IDLE user. When i run my app connected to my laptop these functionalities work. However when i build my app and install it, they no longer work at all.

     ///Handling IDLE USER////////////////
    myHandler = new Handler();
    myRunnable = new Runnable() {
        @Override
        public void run() {
            if(!isFinishing())
            {
                LogOut();
            }
        }
    };
    startHandler();

         @Override
public void onUserInteraction() {
    super.onUserInteraction();
    stopHandler();//stop first and then start
    startHandler();
}

public void stopHandler() {
    myHandler.removeCallbacks(myRunnable);
}
public void startHandler() {
    myHandler.postDelayed(myRunnable, TIMEOUT_IN_MILLI_IDLE); //for 5 minutes
}

/////////////////////When app goes to background/////////////
@Override
protected void onStop() {
    super.onStop();
    if(!isFinishing())
    {
        LogOut();
    }
}

I want my app to logout when back or home button is pressed. Also when the user is idle.

Comments