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

How do I make downloading from and uploading to Google Tasks from my ToDo List app work consistently?

Hi. I'm working on the 7th project--Making a ToDo List App--in the Android Development Techdegree track. I have the main features working but am having some problems with downloading from and uploading to Google Tasks. The first time I download or upload, everything works fine. But in subsequent tries, the app freezes. I don't know why this is. could you guys take a look at my code, especially in the MainActivity file, toward the end, and tell me what I'm doing wrong? Here is a link to my project: https://github.com/slim0926/ToDoList Thanks so much, Sue

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

One thing that stands out to me is you're join()ing your threads immediately after start()ing them. Doesn't that defeat the purpose of using a background thread in the first place?

Does it? I'm sorry I'm completely lost. The reason why I did that is because I needed to know when the background thread finished the work so that I could close the dialog fragment and update my recyclerview of tasks.

Seth Kroger
Seth Kroger
56,413 Points

join() stops the current thread (the main UI thread in this case) and waits for the joined thread to finish. This is the main reason your app locks up. There are other means of waiting for the thread, such as using runOnUiThread() to call a method to update the view.

Thanks! I will try that.