I have a simple question: I'm in a class when I have an Alert Dialog. From this class I get a String value from another class. How can I pass this value to my Fragment? To my Fragment, NOT Activity.
            Asked
            
        
        
            Active
            
        
            Viewed 29 times
        
    0
            
            
        - 
                    Create an interface in alertDialog and implement the interface in your fragment. – Muthukrishnan Suresh Jul 10 '15 at 17:18
- 
                    I already tried it but crash with ClassCastException on: MyInterface callback = (MyInterface) context; – Giorgio Mirini Jul 10 '15 at 17:46
- 
                    @GiorgioMirini can you post snippets of code (to debug the error)? Using an interface is a clean way of doing what you are trying to do. – Virat Singh Jul 10 '15 at 18:18
- 
                    Here's a possible solution: http://stackoverflow.com/questions/13733304/callback-to-a-fragment-from-a-dialogfragment – Virat Singh Jul 10 '15 at 18:20
- 
                    Dont typecast context. implement interface in fragment, send 'this' from fragment to alertdialog and initialise the MyInterface – Muthukrishnan Suresh Jul 11 '15 at 08:51
 
    