I am having TimerTask Thread problems.  Basically I am running a
TimerTask to update a clock timer I have created.  When the user gets
an answer correct a small animation will play and the screen will be
idle for about 5 seconds, then it will resume with the next question.

The problem is that when I flip the G1 screen, the clock will have
already started (Sometimes almost 3/4 through).  It seems to me that
the initial TimerTask thread did not finish and now there are two
different ones running at the same time.  I have cancelled the
TimerTask and the Timer in the onStop() method as seem below.

Any ideas?

In the onStart() methods I have this:


                        mClockTimerTask = new TimerTask() {

                                @Override
                                public void run() {
                                        if(!clockPaused) {
                                                if(mClock.getSweepArc() >= 360) 
{
                                                        clockPaused = true;
                                                        
mHandler.post(skipFromThread);
                                                        mClock.setAngleArc(0);
                                                } else {
                                                        mHandler.post(new 
Runnable() {
                                                                @Override
                                                                public void 
run() {
                                                                        
mClock.setAngleArc(mClock.getSweepArc()+mArcChangePerSecond);
                                                                }
                                                        });
                                                }
                                        }


                                }
                        };

                        mClockTimer = new Timer();
                        mClockTimer.schedule(mClockTimerTask, 0,500);




Here is my onStop() method:

        @Override
        protected void onStop() {
                super.onStop();
                if (Constants.DEBUG_LOG) {
                        Log.d(TAG, "onStop()");
                }

                //Stop the timer
                mClockTimerTask.cancel();
                mClockTimer.cancel();
                mClockTimer = null;
        }
-- 
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