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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:44:53+00:00 2026-06-01T20:44:53+00:00

I’m building a count down timer app and I let the user press a

  • 0

I’m building a count down timer app and I let the user press a button to start the timer. When the button is pressed the timer counts down (work session). The user can then wait for the timer to finish or reset the timer by clicking the same button (re-labeled “Reset”).

If they wait for the timer to finish, another timer is started (short time interval – aka break session). At this point, if they press the button (relabeled “End break”) it cancels the break timer and starts another work session.

For some reason when I click my button it won’t start the timer. in my current setup of the code. I have tested the timer and the button and I know they work.

For some reason my onClick method doesn’t start the timer, any help? Do I have to do something to my CountDownTimer class?

public class SimplyPomodoroActivity extends Activity implements OnClickListener {

    TextView tvTimer; // used to update timer...
    Button btStart; //main button
    Vibrator vibrator; // vibrate when button is pressed..

    boolean off = true;
    boolean working = false;



    long longBreak = 8000; // 900000;
    long shortBreak = 6000; // 300000;
    long workTime = 10000; // 1500000;

    long v = 100; // vibration sequence
    int pomoCount = 1; // keep track of the number of Pomodoros...



    // PomoTimer pomoBreak = new PomoTimer(startTime, interval);

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        initialiaze(); //connect xml to java code and setup listener

    }

    private void initialiaze() {
        tvTimer = (TextView) findViewById(R.id.tvTimer);
        btStart = (Button) findViewById(R.id.btStart);
        vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

        btStart.setOnClickListener(this); // register listener
    }

    @Override
    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        vibrator.vibrate(v);

        //Do stuff
        if(off){ //Turn on
            //change text
            //start work timer --> work timer will go to break automatically
            off = false;
            working = true;
            btStart.setText("Reset");
            workCounter.start();
        }

        if(working){ 
            //turn off
            btStart.setText("Start");
            workCounter.cancel();
            working = false;
            off = true;
        }else if(!working && !off){ 
            //end break
            shortBreakCounter.cancel();
            btStart.setText("Reset");
            workCounter.start();
        }

    }

    CountDownTimer workCounter = new CountDownTimer(workTime, 1000) {

        public void onTick(long millisUntilFinished) {
            displayRemainingTime(millisUntilFinished);
        }

        public void onFinish() {
            tvTimer.setText("0:00");
            working = false;
            pomoIncrement();
            btStart.setText("End Break");
            shortBreakCounter.start();
        }
    };

    CountDownTimer shortBreakCounter = new CountDownTimer(shortBreak, 1000) {

        public void onTick(long millisUntilFinished) {
            displayRemainingTime(millisUntilFinished);
        }

        public void onFinish() {
            working = true;
            pomoIncrement();
            btStart.setText("Reset");
            workCounter.start();
        }
    };

    CountDownTimer longBreakCounter = new CountDownTimer(longBreak, 1000) {

        public void onTick(long millisUntilFinished) {
            displayRemainingTime(millisUntilFinished);
        }

        public void onFinish() {
            pomoIncrement();

        }
    };


    private void pomoIncrement() {
        // increment by one, reset at 8
        pomoCount += (pomoCount > 8) ? -pomoCount : 1;
    }

    private void displayRemainingTime(long millisUntilFinished) {

        // TODO Auto-generated method stub
        int sec = (int) (millisUntilFinished / 1000) % 60;
        int min = (int) ((millisUntilFinished / 1000) / 60);
        tvTimer.setText("" + min + ":" + sec);
    }
}

My count down timer won’t start in my if(off){…} statement… and when i changed it around to other configurations it won’t cancel my current running CountDownTimer..

  • 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-06-01T20:44:56+00:00Added an answer on June 1, 2026 at 8:44 pm

    Add a

    return; 
    

    after

    btStart.setText("Reset");
    workCounter.start();
    

    so the timer isn’t canceled just after the start.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Specifically, suppose I start with the string string =hello \'i am \' me And
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload

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.