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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:45:24+00:00 2026-06-13T12:45:24+00:00

I have plans to create an interval app using timers. It should just be

  • 0

I have plans to create an interval app using timers. It should just be the most basic So I’ll have to add some more when I’ve understood the basics. What I want to achieve is to select the number of minutes an interval should last, yet how many times this interval should go. Like a interval that last 1 minute and goes 8 times.
The question is which timer is best to use? I have tried me on the Android Countdown Timer and it seems to work. But is there another one which is better?

  • 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-13T12:45:25+00:00Added an answer on June 13, 2026 at 12:45 pm

    I would always recommend using a Handler.

    It’s a little more work than the built in classes, but I find that it is vastly more efficient and you have more control over it.

    The Handler is a class that will handle code execution over a specific Looper / Thread by default, the Thread it is created in, Otherwise you can specify where the Handler executes its code by passing in the Looper to the Handler constructor like – new Handler(Looper.getMainLooper());

    The reason I would recommend the looper is because you have a higher flexibility of control, as it is a slightly lower down abstraction over the TimerTask methods.

    Generally they are very useful for executing code across threads. E.g. useful for piping data across threads.

    The two main uses are:

    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
    
        final Handler h = new Handler();
        h.postDelayed(new Runnable()
        {
            private long time = 0;
    
            @Override
            public void run()
            {
                // do stuff then
                // can call h again after work!
                time += 1000;
                Log.d("TimerExample", "Going for... " + time);
                h.postDelayed(this, 1000);
            }
        }, 1000); // 1 second delay (takes millis)
    }
    

    Simple use!

    Or you can use messages, which reduce object creation. If you are thinking about high speed updating UI etc – this will reduce pressure on the garbage collector.

    class MainActivity extends Activity {
    
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
    
            MyTimers timer = new MyTimers();
            timer.sendEmptyMessage(MyTimers.TIMER_1);
            timer.sendEmptyMessage(MyTimers.TIMER_2);
    
        }
    
    
        public static class MyTimers extends Handler
        {
    
            public static final int TIMER_1 = 0;
            public static final int TIMER_2 = 1;
    
            @Override
            public void handleMessage(Message msg)
            {
                switch (msg.what)
                {
                    case TIMER_1:
                        // Do something etc.
                        Log.d("TimerExample", "Timer 1");
                        sendEmptyMessageDelayed(TIMER_1, 1000);
                        break;
                    case TIMER_2:
                        // Do another time update etc..
                        Log.d("TimerExample", "Timer 2");
                        sendEmptyMessageDelayed(TIMER_2, 1000);
                        break;
                    default:
                        removeMessages(TIMER_1);
                        removeMessages(TIMER_2);
                        break;
                }
            }
        }
    }
    

    Obviously this is not a full implementation but it should give you a head start.

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

Sidebar

Related Questions

I have plans to create an app which gives me the list of words
I have been making plans to create a site that would contain several different
Using information from some of the questions here on generic views, I have created
Does anyone know if there have been any efforts or plans to create a
I have plans to set up a website where people can create an account
I have an application with three modules: default , disciplines and plans . In
I currently have a Ruby on Rails system, and there are plans to port
I have a JMeter test plan with following http request samplers. Login Call some
I have been tasked with a project where I am to add a new
Hello I’m a trying to create a feature where an user an add an

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.