The issue is that I haven't result because the image picker doesn't open from the fragment, if I click/touch the ImageView, nothing happens, instead with the same code in the Activity, the image picker opens and I can select an image from the gallery, so in this way I have the result. Using the fragment and reading the logcat, there isn't anything about the issue...It's a mistery
Ulf Dittmer wrote:
I use only the piece of code about the action, it doesn't work.
That was my earlier question: how does it not work? What did you do, what did you expect to happen as a result, and what happened instead? What concrete steps have you taken so far to investigate the issue?
If I use all the code of the Fragment as Activity, the action works, instead if I use only the piece of code about the action, it doesn't work.
Ulf Dittmer wrote:I'm confused - earlier you said the code worked fine when part of an activity. But now it doesn't?
The first thing to investigate whenever an event handler seems to have no effect is to find out if it is ever actually called.
I used this code in the MainActivity but nothing happens if I click the ImageView:
Ulf Dittmer wrote:My favorite approach for communication between various components of an app is the EventBus library.
Or you can cast getActivity() to whatever class it actually is, and then make a direct method call.
I'm probably wrong understanding but I need to use a Fragment and not an Activity because I'm using the DrawerLayout in the MainActivity
Ulf Dittmer wrote:That may not be possible - what's the issue with having the associated activity do it instead?