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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:32:29+00:00 2026-05-20T00:32:29+00:00

i am creating media recorder demo application. for that i have take two button

  • 0

i am creating media recorder demo application. for that i have take two button start and stop.
i want to display timer when click on start button and want to stop on stop button.

any idea?

Thanks

  • 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-20T00:32:29+00:00Added an answer on May 20, 2026 at 12:32 am

    Simple solution can be based on these classes:

    public static class TimeCounter{
        private long startTime;
    
        public TimeCounter(){
            startTime = new Date().getTime();
        }
    
        public long countTime(){
            return new Date().getTime() - startTime;
        }
    }
    
    public class TimeCounterTask extends AsyncTask<TimeCounter, Long, Void>{
    
        @Override
        protected Void doInBackground(TimeCounter... params) {
            TimeCounter tc = params[0];
            while(true){
                publishProgress(new Long(tc.countTime()));
                try{
                    Thread.sleep(500);
                } catch(InterruptedException e){
                    break;
                }
            }
            return null;
        }
    
        @Override
        protected void onProgressUpdate(Long... values) {
            super.onProgressUpdate(values);
            long millis = values[0].longValue();
            int minutes = (int) ((millis / 1000) / 60);
            int seconds = (int) ((millis / 1000) % 60);
            String s = String.format("%d min, %d sec", 
                    minutes, seconds);
            timerText.setText(s);
        }
    
    }
    
    • in start button handler create new TimerCounterTask and execute it this new TimerCounter() parameter
    • in stop button handler stop current task
    • timerText is TextView for display timer
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When creating a web application, and lets say you have a User object denoting
Creating hashes of hashes in Ruby allows for convenient two (or more) dimensional lookups.
While creating classes in Java I often find myself creating instance-level collections that I
I am creating a video recorder and would like to create video player to
I am using Windows Vista x86 + VSTS 2008. When creating new Windows Media
I am currently creating a set of custom media types for a RESTful api
I am using media player to play audio and video. I am creating own
How do I go about creating my own taskbar toolbar, a la Windows Media
Is there any free media player control library that allows us to play videos
I'm creating a msi based installer (using InstallShield) that has a custom action to

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.