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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:40:41+00:00 2026-05-26T15:40:41+00:00

Ok ths is becomming annoying! I can’t really stop the timer,only pause it… I

  • 0

Ok ths is becomming annoying!
I can’t really stop the timer,only pause it…
I have a function that makes x be a new timer everytime the function is called.What I need,is to sometimes stop the timer and start allover again.The problem is that if I use cancel,it pauses it and when I call the function to make a new one,it actually continues the one that wa s paused! Please help me so I can sleep…

public void countdown(){


        final TextView textic = (TextView) findViewById(R.id.textView2);

        x = new CountDownTimer(30000, 1000) {

        public void onTick(long millisUntilFinished) {
            textic.setText("Seconds remaining: " + millisUntilFinished / 1000);

        }

        public void onFinish() {
            textic.setText("Time expired");
            idiot();
            getfirstquestion();

        }
        };

        x.start();
    }

That’s the function,and the x is decleared as a global variable at the beginning.What is need is: when I press a button(even 100 times) make the current timer stop,and start a really new one(like in that function).

  • 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-26T15:40:42+00:00Added an answer on May 26, 2026 at 3:40 pm

    Just cancel the old one before you create the new one.

    public void countdown(){
        final TextView textic = (TextView) findViewById(R.id.textView2);
    
        if (x != null) {
            x.cancel();
        }
    
        x = new CountDownTimer(30000, 1000) {
    
        public void onTick(long millisUntilFinished) {
            textic.setText("Seconds remaining: " + millisUntilFinished / 1000);
    
        }
    
        public void onFinish() {
            textic.setText("Time expired");
            idiot();
            getfirstquestion();
    
        }
        };
    
        x.start();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive got ths really annoying issue I have grouped a set of data and
How can I expand ths function with a search field for a location? <tr>
I have ths function to query a set of records from the DB: public
I have been looking through ths hashlib documentation but haven't found anything talking about
I had a small WTF moment this morning. Ths WTF can be summarized with
I have two TextViews that displays numbers from 1-6, I need to make a
I have a ListView in Android that I want to split in pages that
I have a shopping cart in my app and an underlying data structure that
Visual Studio has a size and distance specification chart that says I can do
I use ths script in Default.aspx page. <script id=clientEventHandlersJS type=text/javascript> function Button1_onclick() { var

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.