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 Upgrading Our Thread

I need some clarification about Looper and mHandler (t=01:37)

I've spent several hours re-watching the video, making pages of notes, trying to understand these new concepts (e.g. Message, Looper, etc), and I believe I almost got it. I have a few questions about the content in class DownloadThread.java.

Q.1) Is the mHandler object created during initial run (when thread.start() is executed, see class MainActivity.java) even when no messages are sent (because the mDownloadButton was not clicked)? If it was created during initial run, it would miss an argument for downloadSong method in DownloadHandler.java.

Q.2) Can the following be confirmed: When a message is processed by the mHandle object it will not cease to exists (i.e. not re-instantiated)?

For illustrative purposes:

Looper.prepare()
mHandler     // instantiated from DownloadHandler class
Looper.loop() 
(a message arrives)
mHandler     // takes arbitrary data attached to message (when queryButton is clicked)
downloadSong(message)    // pass data attached to message as argument to method (DownloadHandler.java)
Looper.loop()
(a message arrives)
mHandler     // takes arbitrary data attached to message (when queryButton is clicked)
downloadSong(message)    // pass data attached to message as argument to method (DownloadHandler.java)

Thanks in advance,