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

  • SEARCH
  • Home
  • 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 3930526
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:15:55+00:00 2026-05-19T23:15:55+00:00

I have a need for a very simplistic way to keep track of time.

  • 0

I have a need for a very simplistic way to keep track of time. Basically I simply need to start a timer when a method is called, and a set amount of time after that (45-90 seconds) call another method.

From what I have read, Handlers are the most efficient way to handle keeping track of time. However, some say they require a second thread, while others say they don’t. It’s certainly not a huge deal, but I would prefer to keep things as minimalistic as possible. So, is there any way to do something like simply checking to see if System.getCurrentTimeMillis is a certain amount higher than it was when the user called the first method, without any further user interaction of course.

If not I will just read into Handlers more and work with those. Thank you for your help.

  • 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-19T23:15:56+00:00Added an answer on May 19, 2026 at 11:15 pm

    After you call your first method you call the second method after 90 seconds with:

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                //here call the second method
    
                }   
    
    }, 90000);
    

    However, if the user clicks on return and leave the activity, this postdelayed runnable will restart the activity, hence you need to put an if statement in it to check if that activity is still running…

    If you need to monitor how much time has passed every 1 second before the timer has ended then you can use this code

    new CountDownTimer(90000, 1000) { 
    
        public void onTick(long millisUntilFinished) { 
            //call to my UI thread every one second 
        } 
    
        public void onFinish() { 
            //final call to my UI thread after 90 seconds
        } 
     }.start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a very specific function in PHP. Basically, I have two strings as
I am very much a beginner to rails and I have a specific need
I have a very specific case that I need to debug. I need to
I have a very long text and I need to hide everything except the
I have a very huge file in which I need to obtain every nth
I have very very big html page/data. I need to fetch data under h1
I have a very different requirement in my app.Using the app i need to
I have a very large data file with around 60000 rows. I need to
I have 2 tables in a DB with very similar schemas that need to
I have a very big CSV file (1GB+), it has 100,000 line. I need

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.