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 Build a Self-Destructing Message Android App Capturing Photos and Videos Taking a Video Using an Intent

Nathaniel Janick
Nathaniel Janick
11,671 Points

Self-Destructing Message: Overflow menu bug

While running my app on the emulator, I've come across a bug. Since adding the Camera Icon in the Action Bar, the AlertDialog for camera options now pops up for a moment when I select the "Edit Friends" option. Wondering if this is me, the emulator, or something that gets fixed later in the app. I'll try posting the possible culprit code once I locate it, but if anyone has any suggestions as to where the problem might lie, please let me know.

2 Answers

Paul Stevens
Paul Stevens
4,125 Points

Hello,

This is fixed later in the app. It's a missing Break; in the switch statement.

This is a small part of a switch statement:

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int itemId = item.getItemId();

        switch(itemId) {
            case R.id.action_logout:
                ParseUser.logOut();
                navigateToLogin();
                break;

First thing I would suggest is check any of these Switch statements and make sure each one has that break; as the last line. If it doesn't the program will keep going and get confused. I think later on, Ben spots a mistake in this and shows us what to do. Keep going with the videos if my answer doesn't help. :)

I hope this helps, Paul

Nathaniel Janick
Nathaniel Janick
11,671 Points

Thanks for the help! I had a feeling after looking at my code that was the problem, but wasn't sure how switches and breaks mixed with intents. I'll breathe easier knowing that it will eventually be fixed now.