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 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

i am creating one iPad application in that i want to open media player
Im currently creating a PHP application that searched various Social Media and analyses the
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
I am creating an android that acts as a media center. I would like
I have my website that I am creating here and it's looking good (right
I am creating a editor kind of application where I want to compile and
I have a PHP file that generates a Media RSS file for the embedded
I am creating a application using jmf that will be launched on a user's
I'm creating a countdown timer that allows the user to choose a valid time,
I'm creating a custom media center wordpress website. I have created my own gallery,

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.