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 Sending Messages Selecting Recipients

Pedro Guimaraes
Pedro Guimaraes
2,671 Points

Whenever I click "Edit Friends" in the action bar menu the Dialog for choosing media shows up

I can't figure out what is going on, whenever I click on the action bar "Edit Friends" button the dialog for choosing media shows up for a second and then the app goes to the actual Edit Friends fragment.

Here are my project files: https://dl.dropboxusercontent.com/u/24445885/Ribbit.zip

Video of the bug: https://www.youtube.com/watch?v=Fk2dXSNu0J4

Pedro Guimaraes
Pedro Guimaraes
2,671 Points

If I comment out these lines:

    ```java
                    case R.id.action_camera:
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setItems(R.array.camera_choices, mDialogListener);
        AlertDialog dialog = builder.create();
        dialog.show();
    }```

It doesn't happen but that is not exactly a solution

4 Answers

That would be in the onOptionsItemSelected method inside MainActivity.

switch(itemId) {
 ... 
    case R.id.action_edit_friends:
         // do stuff
    break;
    case R.id.action_camera:
        ....
    break;
}

I can't get into your zip file for some reason ... anyway, have you got a break after your switch case options? If not, it may execute them all.

http://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html

Pedro Guimaraes
Pedro Guimaraes
2,671 Points

Thanks, that was the problem :)

I had the same issue, thanks.