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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:41:46+00:00 2026-05-26T04:41:46+00:00

Calling: Intent i = new Intent(Timer.this,TimerService.class); i.putExtra(ms, ms); startService(i); code: public class TimerService extends

  • 0

Calling:

            Intent i  = new Intent(Timer.this,TimerService.class);
            i.putExtra("ms", ms);
            startService(i);

code:

public class TimerService extends Service{

    CountDownTimer timer;
    Chronometer clock;
    @Override
    public IBinder onBind(Intent intent) {

        return null;
    }
    public void setClock (Chronometer cron)
    {
        this.clock = cron;
    }
    @Override
    public void onStart(Intent intent, int startId) {
        // TODO Auto-generated method stub
        int ms = intent.getIntExtra("ms", 0);

        timer = new  CountDownTimer(ms,1000){
            @Override
            public void onTick(long millisUntilFinished) {

                int seconds = (int) (millisUntilFinished / 1000) % 60 ;
                int minutes = (int) ((millisUntilFinished / (1000*60)) % 60);
                int hours   = (int) ((millisUntilFinished / (1000*60*60)) % 24);

                clock.setText( String.format("%02d:%02d:%02d", hours,minutes,seconds));
                Log.e("Timer", String.valueOf(millisUntilFinished));

            }

            @Override
            public void onFinish() {
                // TODO Auto-generated method stub

            }
        }.start();
        super.onStart(intent, startId);
    }

I have a timerservice, and i want to update the Chronmeter(like a TextView) in the onTick() method. I don’t know how to get access to that. please help

  • 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-26T04:41:47+00:00Added an answer on May 26, 2026 at 4:41 am

    maybe you can use AsyncTask ? http://developer.android.com/reference/android/os/AsyncTask.html

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

Sidebar

Related Questions

If I have the following code: Intent intent = new Intent(this,DownloadService.class); for(int i=0;i<filesArray.length;i++){ startService(intent);
I have an Activity calling a Service defined in IDownloaderService.aidl: public class Downloader extends
after calling: result=bindService(new Intent(IUdpListenerService.class.getName()), serviceConnection, Context.BIND_AUTO_CREATE); byt debugger: result return 'true' the onServiceConnected isn't
I have created a Alarm using AlarmManager. Intent intent = new Intent(MyApp.this,NotificationMessage.class); PendingIntent sender
I have a snippet of code that I'm calling from a service: context.registerReceiver(new BroadcastReceiver()
I have a alarm manager which is calling an activity class named ScheduleAlert. public
Can someone tell if why when starting an activity with startActivity(intent) , calling getParent()
When calling a remote service (e.g. over RMI) to load a list of entities
I've got a float array camObjCoord declared as.. public static float camObjCoord[] = new
In a TabHost widget, I can create a new tab with its content (Intent)

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.