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

Android Threads and Services Threads in Android Upgrading Our Thread

I wanted to call the sendMessage method just like the teacher did in the MainActivity but it wasn't recognized

the sendMessage methode wasn't recognized when I tried to call it in the thread.mHandler

2 Answers

Quaide Simek
Quaide Simek
Courses Plus Student 233 Points

One suggestion is to check that your mHandler class is extending android.os.Handler, not java.util.logging.Handler. I made that mistake, and upon changing everything else fell into place.

Paritosh Sahni
Paritosh Sahni
Courses Plus Student 4,853 Points

For anybody who will face the same problem in the future. Well, you need to declare your DownloadHandler public for it to be recognised by the Thread on which you will send the message.

public DownloadHandler mHandler;

Once you do this thread will recognise mHandler