Ok so I've been able to get the timer some what functional using a
timer and handler. Only problem I am having is when I run it in the
emulator the seconds are ticking down by 2 and have some delay here
and there. I've tried playing with some numbers but all I've been able
to change is instead of counting down by evens, is counting by odds.
I've tried to change the millisecond count times but nothing..
Any help would be appriciated.
Here's some of the code for the count down:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    updateTimer = new Timer();
    updateTimer.schedule(doRefresh, 1000); // Tried changing this to
many numbers but nothing happened

......

public void setUpdateTimer(Timer updateTimer) {
        this.updateTimer = updateTimer;
}

public Timer getUpdateTimer() {
        return updateTimer;
}

// reate handler and timer
private Handler handler = new Handler();
private TimerTask doRefresh = new TimerTask() {
           public void run()
    {
        //Get Dates & Convert both into miliseconds.
    long Todays_Date = new GregorianCalendar().getTimeInMillis(); //
Get current Date & Time
    long Target_Date = new GregorianCalendar(2010, 5, 30, 0, 0,
1).getTimeInMillis();
    long diff = Math.round((Target_Date - Todays_Date) / 1000);
    if (diff > 0)
    {
    days  = (int) Math.floor(diff / 86400); // Days
    diff = diff % 86400;
    hours = (int) Math.floor(diff / 3600); // Hours
    diff = diff % 3600;
    minutes = (int) Math.floor(diff / 60); // Minutes
    diff = diff % 60;
    seconds = (int) (diff ); // Seconds
    }
    handler.postDelayed(this,1000); // Tried changing this to 0 but
made no differance
    .....
    }
    };

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to