Auto logout of application
<p>I am trying to implement an auto logout functionality. If the application is not used for a period of 1 hour i would want to automatically bring the user to the login screen. When the phone gets locked the thread which is monitoring if the application is in use does not seem to continue. My code is as below:</p>

<pre><code>/**
 * This Deamon checks if the application is idle and 
 */
private class LogoutDeamon extends Thread {

    public void run() {

        while (!logoutDeamon) {
            try {
                System.out.println("Logout Counter:" + logoutConter);
                if (logoutConter &lt;= 0) {
                    logoutDeamon = true;
                ApplicationManager.getInstance().setLoggedOut(true);
                   ApplicationManager.getInstance().Log(Level.INFO, "Auto Log out");
                   logout();
                } else {
                    decreamentCounter();
                }
                sleep(60000 * 1);
            } catch (ParserException ex) {
                Log(Level.ERROR, " Par. Ex. in Logout-Deamon:" + ex.getMessage());
                logout();

            } catch (ServerException ex) {
                Log(Level.ERROR, " Ser. Ex. in Logout-Deamon:" + ex.getErrorMessage());
                logout();
            } catch (InterruptedException ie) {
                Log(Level.ERROR, "Int. Ex. in Logout-Deamon:" + ie.getMessage());
            } catch (Exception ex) {
                Log(Level.ERROR, "Erro in Logout-Deamon:" + ex.getMessage());
                logout();
            }
        }
    }

    private void logout(){
        Intent broadcastIntent = new Intent();
        broadcastIntent
                .setAction("com.package.ACTION_LOGOUT");
        applicationContext.sendBroadcast(broadcastIntent);

        Intent loginIntent = new Intent(applicationContext,
                Login.class);
        loginIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        applicationContext.startActivity(loginIntent);
    }

}
</code></pre>

<p>Am i missing out on something? Can someone kindly help me with this. Thanks in advance.</p>
