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

Edit Friends shows the camera dialog when backing out?

Hello,

I have just set up the camera intent on my app and have noticed that if I open Edit Friends and back out, I see the dialog as if I had tapped on the camera icon. This only happens when I press the devices back button though. I've included a video with a debug too which shows this happening and better describes this:

https://www.youtube.com/watch?v=SuebRkGa8s0&feature=youtu.be

If anybody knows why this occurs, it would be great to know!

1 Answer

Hey Harry! This is due to the code in your switch statement. There should be a break; as the last line of each case, so that it will "break" out of the switch statement after the code in the case is executed, instead of "falling through" to the code in the next case as you saw happen when you were debugging. What happened was that the camera dialog opened up behind the Edit Friends page, so when you pressed the back button, you were able to view it. By inserting the break statements, the show() method for the camera's dialog won't be called when you press Edit Friends.

Ben accidentally left the break statements out, but he fixes it in a later video: the Deleting the Whole Message video under the Self-Destruction stage. He notices the error at around 3:45 and then goes on to add the break statements at around 4:11.

Ah! Thanks for this! Marked as best answer :)