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 6718473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:58:24+00:00 2026-05-26T08:58:24+00:00

I am trying to get a timer running, but I get a weird bug

  • 0

I am trying to get a timer running, but I get a weird bug when my timer starts. It starts counting from -214342352:00. I have looked through http://developer.android.com/resources/articles/timed-ui-updates.html but couldn’t find what’s wrong with my code.

private Handler mHandler = new Handler();
private long mStartTime = 0L;

Start timer

if (mStartTime == 0L) {
             mStartTime = System.currentTimeMillis();
             mHandler.removeCallbacks(mUpdateTimeTask);
             mHandler.postDelayed(mUpdateTimeTask, 1000);
}

Runnable

public Runnable mUpdateTimeTask = new Runnable() {
       public void run() {


           final long start =  mStartTime;
           long millis = SystemClock.uptimeMillis()-start;
           int seconds = (int) (millis / 1000);
           int minutes = seconds / 60;
           seconds     = seconds % 60;

           if (seconds < 10) {
              alarmCounter.setText("" + minutes + ":0" + seconds);
           } else {
              alarmCounter.setText("" + minutes + ":" + seconds);            
           }

         //  mHandler.postAtTime(this,start + (((minutes * 60) + seconds + 1) * 1000));
        mHandler.postDelayed(this, 1000);

       }
    };
  • 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-26T08:58:25+00:00Added an answer on May 26, 2026 at 8:58 am

    You are using two different systems of measurement. Either use SystemClock.uptimeMillis() or use System.currentTimeMillis() for all your measurements.

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

Sidebar

Related Questions

OK. So I have been trying to implement a timer. Now a very weird
I'm trying to get into Java web development but seem to be running into
I am trying to get the current time of a running animation but I
I'm trying to get someone else's app up and running on my development laptop
I am running windows 7 and I am trying to get this IDE to
I am trying to get MonoDevelop 2.4 to run on a PowerPC Mac running
I'm trying to get assetics running with the yui compressor and, if this is
Trying to get a simple COUNT from a table that takes a couple of
I'm trying to get a set of reports running in an (VB) ASP.NET project
I have been running through alot of issues try to pause and unpause a

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.