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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:53:41+00:00 2026-05-22T11:53:41+00:00

I made an application in android and used timer like this.. try { CountDownTimer

  • 0

I made an application in android and used timer like this..

try {
    CountDownTimer  start1 = new CountDownTimer(20000, 1000) {

        public void onTick(long millisUntilFinished) {
                TextView timeShow = (TextView)findViewById(R.id.showTime);
        timeShow.setText(" "+" 00:" +millisUntilFinished / 1000);
            }

But my problem is i don’t know how to stop timer. Any idea?

I already tried:

quitApplication.setOnClickListener(new OnClickListener() {
    public void onClick(View v) { 
        start1.cancel(); 
        Intent i = new Intent(v.getContext(), startGame.class);
        startActivity(i);
        // TODO Auto-generated method stub 
    } 
}); 
  • 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-22T11:53:41+00:00Added an answer on May 22, 2026 at 11:53 am

    start1.cancel() is the correct method to call to cancel the timer.

    You did not provide any details about the error you got or why it didn’t work for you, but I am assuming your program didn’t compile because your variable start1 is a local variable. It is probably local to whatever method your try block is in. This means your OnClickListener construction has no idea what start1 is.

    To fix this simply declare start1 as a class variable (outside of all methods but within the class):

    public class someClass {
    
    CountDownTimer start1;
    // blah some code
    public void someMethod {
       try {
          start1 = new CountDownTimer() { //etc
    

    Doing so will allow other methods to recognize and interact with start1

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

Sidebar

Related Questions

I made an application that is using Android SDK 2.1. This application uses bluetooth
I have made a SVG image, or more like mini application, for viewing graphs
I created an application which is currently on Android market. The key used to
i have made an android application for Project Build Target as Target name:: Android
I have a little problem... I have made an Android application which extends the
I'm currently developing an application for Android which needs to use a custom made
I made an application for Android and I wanted to install the application on
i have made an android application and in it , there is one scenario
Last year I made an Android application that scrapped the informations on my train
I have made a ListView in my android application. But the problem is that

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.