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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:01:29+00:00 2026-06-01T14:01:29+00:00

For example: in the Activty A I have a Chronometer , I click on

  • 0

For example: in the Activty A I have a Chronometer, I click on play to start it and when it arrives at 00:00:10 I decide to go to Activity B. I stay on it for 30 seconds before returning to A. I would find the timer paused still displaying 00:00:10, but I’d like to see it still running and then at 00:00:40. How can I do this? How can I avoid the timer pausing on the change of Activity?

  • 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-01T14:01:30+00:00Added an answer on June 1, 2026 at 2:01 pm

    (Based on the answer given for Get time of chronometer widget, with code for and extra activity added.)

    The main activity:

    package com.so.chilledrat.chronoexample;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.SystemClock;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.Chronometer;
    import android.widget.LinearLayout;
    import android.widget.Toast;
    
    public class ChronoExampleActivity extends Activity {
        Chronometer mChronometer;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            LinearLayout layout = new LinearLayout(this);
            layout.setOrientation(LinearLayout.VERTICAL);
    
            mChronometer = new Chronometer(this);
            layout.addView(mChronometer);
    
            Button startButton = new Button(this);
            startButton.setText("Start");
            startButton.setOnClickListener(mStartListener);
            layout.addView(startButton);
    
            Button stopButton = new Button(this);
            stopButton.setText("Stop");
            stopButton.setOnClickListener(mStopListener);
            layout.addView(stopButton);
    
            Button resetButton = new Button(this);
            resetButton.setText("Reset");
            resetButton.setOnClickListener(mResetListener);
            layout.addView(resetButton);
    
            Button switchButton = new Button(this);
            switchButton.setText("Switch Activity");
            switchButton.setOnClickListener(mSwitchListener);
            layout.addView(switchButton);
    
            setContentView(layout);
        }
    
        private void showElapsedTime() {
            long elapsedMillis = SystemClock.elapsedRealtime() - mChronometer.getBase();
            Toast.makeText(this, "Elapsed milliseconds: " + elapsedMillis, Toast.LENGTH_SHORT).show();
        }
    
        View.OnClickListener mStartListener = new OnClickListener() {
            public void onClick(View v) {
                mChronometer.start();
                showElapsedTime();
            }
        };
    
        View.OnClickListener mStopListener = new OnClickListener() {
            public void onClick(View v) {
                mChronometer.stop();
                showElapsedTime();
            }
        };
    
        View.OnClickListener mResetListener = new OnClickListener() {
            public void onClick(View v) {
                mChronometer.setBase(SystemClock.elapsedRealtime());
                showElapsedTime();
            }
        };
    
        View.OnClickListener mSwitchListener = new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent myIntent = new Intent(ChronoExampleActivity.this.getBaseContext(), OtherActivity.class);
                startActivityForResult(myIntent, 0);
            }
        };
    }
    

    The other activity to switch to:

    package com.so.chilledrat.chronoexample;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    
    public class OtherActivity extends Activity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            LinearLayout layout = new LinearLayout(this);
            layout.setOrientation(LinearLayout.VERTICAL);
    
            Button switchButton = new Button(this);
            switchButton.setText("Switch Back");
            switchButton.setOnClickListener(mSwitchListener);
            layout.addView(switchButton);
    
            setContentView(layout);
        }
    
        View.OnClickListener mSwitchListener = new OnClickListener() {
    
            @Override
            public void onClick(View v) {
                // Intent myIntent = new Intent(OtherActivity.this.getBaseContext(),
                // ChronoExampleActivity.class);
                // startActivityForResult(myIntent, 0);
                finish();
            }
    
        };
    }
    

    And finally the manifest:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.so.chilledrat.chronoexample"
        android:versionCode="1"
        android:versionName="1.0" >
    
        <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="7" />
    
        <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name" >
            <activity
                android:name=".ChronoExampleActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity android:name="OtherActivity"></activity>
        </application>
    
    </manifest>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 classes in my example: Class A, the main activity. Class A
I have an activity defined as below: <activity android:name=com.example.ui.HomeActivity android:alwaysRetainTaskState=true/> A strange thing is
I have this menu example But in this example new activity is not called,
I have this code: public class Chronom extends Activity { Chronometer mChronometer; ProgressBar progre;
I have main activity which call other object, for example GPS class. This GPS
I have an activity which is called by a few other activities. For example,
In my activity I have for example SQLiteDatabase db = openOrCreateDatabase(Preferences.DB_NAME, Context.MODE_PRIVATE, null); db.execSQL(CREATE
In my example activity, I have - a ListView containing - multiple HorizontalScrollView containing
I have created a an activity named Example which have 3 LinearLayouts . I
I have 1 activity, but would like to have multiple context menu's for different

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.