Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Timer Stop

mHandler = new Handler();
    Runnable runnable = new Runnable(){

        public void run(){
                        catch(InterruptedException e){
                            mHandler.post(new Runnable(){
                                public void run(){

                                    if(mtimerinbackground == 50){
                                        mtimerinbackground = 60;
                                        Intent intent = new Intent(PlayScreen.this, Statistics.class);
        new Thread(runnable).start();

Okay so this is a timer and I don't know how to stop it. Could someone please help me??

1 Answer

Well I can't really make out much from this code snippet. What I can guess as of now that there could be a problem of a race condition where more than one instance of a thread is calling the same Intent object. It's just a guess as of now. If you could share some of the main context of the code here maybe it would get more clearer.