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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:55:09+00:00 2026-05-26T07:55:09+00:00

I am wonder why this code doesn’t work. Is it because of the constructor?

  • 0

I am wonder why this code doesn’t work. Is it because of the constructor?

import android.os.Bundle;
import android.view.Window;
import android.widget.TextView;
import android.content.Intent;
import android.app.Activity;
import java.util.Timer;
import java.util.TimerTask;

public class ClockMain extends Activity {

int Hours;
int Minutes;
int Seconds;

String TimeOfDayS;

TextView HoursMainV;
TextView MinutesMainV;
TextView SecondsMainV;
TextView TimeOfDayMainV;

Timer oneSecond;

public ClockMain(int Seconds) {
    // TODO Auto-generated constructor stub
    oneSecond = new Timer();
    oneSecond.schedule(new SecondsTask(), Seconds * 1000);

}
class SecondsTask extends TimerTask {
    public void run() {
        new ClockMain(1);
        ++Seconds;
        if(Seconds == 60){
            ++Minutes;
            Seconds = 0;
            if(Minutes == 60) {
                ++Hours;
                Minutes = 0;
                if(Hours == 12){
                    if(TimeOfDayS.equals("AM")) {
                        TimeOfDayS = "PM";
                    } else{
                        TimeOfDayS = "AM";
                    }
                    Hours= 0;
                }
            }
        }
        HoursMainV = (TextView) findViewById(R.id.HoursMainV);
        HoursMainV.setText(""+Hours);

        MinutesMainV = (TextView) findViewById(R.id.MinutesMainV);
        MinutesMainV.setText(":"+Minutes);

        SecondsMainV = (TextView) findViewById(R.id.SecondsMainV);
        SecondsMainV.setText(":"+Seconds);

        TimeOfDayMainV = (TextView) findViewById(R.id.TimeOfDayMainV);
        TimeOfDayMainV.setText(" "+TimeOfDayS);
    }
}
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.clock_main);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    Bundle extras = getIntent().getExtras();
        if (extras == null) {
            return;
        }
    int Hour = extras.getInt("HoursS");
    Hour = Hours;
    int Minute = extras.getInt("MinutesS");
    Minute = Minutes;
    int Second = extras.getInt("SecondsS");
    Second = Seconds;
    String TimeOfDaySs = extras.getString("TimeOfDayS");
    TimeOfDaySs = TimeOfDayS;
    HoursMainV = (TextView) findViewById(R.id.HoursMainV);
    HoursMainV.setText(""+Hour);

    MinutesMainV = (TextView) findViewById(R.id.MinutesMainV);
    MinutesMainV.setText(":"+Minute);

    SecondsMainV = (TextView) findViewById(R.id.SecondsMainV);
    SecondsMainV.setText(":"+Second);

    TimeOfDayMainV = (TextView) findViewById(R.id.TimeOfDayMainV);
    TimeOfDayMainV.setText(" "+TimeOfDaySs);
    new ClockMain(1);

}
  }

And yes I did change the Manifest and I know there is not a problem with the xml. It stopped running when I added the public Clock Main and the SecondsTask Class. Please help. If there is a better way of doing this specific to android, I would love to learn it or if I am missing something I would like to know that too.

  • 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-26T07:55:09+00:00Added an answer on May 26, 2026 at 7:55 am

    Instead of passing int seconds in constructor,
    You should pass it through Intent and in onCreate() of the Activity and then you can start and schedule the timer for this Activity.

    onCreate() may be considered as Constructor for the Activity.

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

Sidebar

Related Questions

I'm wonder why this simple code doesn't work. In main.py I have def foo():
I have a problem with this jQuery code. It doesn't work as expected: $('#select_dropdown').change
I wonder why Java compiler doesn't trust in this line of code : List<Car>
I'm seeing this code in a project and I wonder if it is safe
This is my first question on stackoverflow. I just wonder why my getJSON code
I have this little piece of code: <script> $(window).bind('beforeunload', function() { $.ajax({ async: false,
I wonder if this would be doable ? To insert an array into one
I wonder if this is possible with ant and java : I have a
I wonder if this affects performance or memory consumption a lot. I need an
i wonder what this query means: $blogPost = Doctrine_Query::create()->from('BlogPost p')->where('p.slug = ?', 'doctrine-released')->execute(); could

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.