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 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.