Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6164695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:02:13+00:00 2026-05-23T22:02:13+00:00

I am trying to implement an auto logout functionality. If the application is not

  • 0

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:

/**
 * 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 <= 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);
    }

}

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:02:13+00:00Added an answer on May 23, 2026 at 10:02 pm

    I don’t think that you need a thread. Register the time in onPause. In onResume test if 1 hour has passed. If not, reset the timer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement auto-rotation in my application that is basically UINavigationController with lots
We are trying to implement a REST API for an application we have now.
I am trying to implement AJAX in my Google App Engine application, and so
I'm trying to implement an automatic timeout inside of an existing PHP application. My
I'm trying to implement a facebook search in my system (auto suggest while typing).
I am trying to implement this jQuery auto complete function but the problem is
I'm trying to implement a simple activity that will let user to insert a
I'm trying to implement spring-security to handle authentication and authorization of my web application.
Hi I have been trying to implement auto complete in my site from 2
All I am currently trying implement something along the lines of dim l_stuff as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.