Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Threads and Services Threads in Android Extending Thread

Jahdiel Alvarez
Jahdiel Alvarez
10,566 Points

New inner class is not seen by compiler.

The compiler doesn't seem to see the inner class created, which extends Thread.

MainActivity.java
public class MainActivity extends Activity {
    final TwitterClient twitterClient = new TwitterClient();

    @Override
    public void onCreate(Bundle savedInstanceState) {
      setContentView(R.layout.activity_main);

      Awesome t = new Awesome(twitterClient);
      t.setName("TwitterThread");
      t.start();
    }

    private class Awesome extends Thread {

        private TwitterClient mTwit;
        public Awesome(TwitterClient t) {
          mTwit = t;
        }

        @Override
        public void run(){
            mTwit.update();    
        }
  }


}

2 Answers

Jason Wiram
Jason Wiram
42,184 Points

The challenge verification must use a default constructor for your new inner class (not that you would or should know this). Since you created a custom constructor, when the verification is running it is not passing because your inner class constructor doesn't match what it is expecting. If you add a default constructor to your class it will pass. As a tip, when doing these challenges, if you add a custom constructor, I would always add a default as well. It's hard to predict what the test validation is using. Just add this to your inner class:

public Awesome() {}
Jahdiel Alvarez
Jahdiel Alvarez
10,566 Points

Thanks, I already solved it the problem as you said was in adding the constructor and making the class private.