GetActivity () returns null after returning from the dialog box

I'm currently having issues with DialogFragment.

My application is as follows:

A MainActivity using an ActionBarSherlock to display 6 tabs (each of which contains a fragment) On one of these tabs, I show DialogFragment when the user clicks a button. This dialog box contains some EditText and a button that saves user input (mailing address) and calls the listener in MainActivity for calculations.

My problem is that when I turn on the screen with the dialog box, I managed to make it stay on the screen without losing data, but when I call the listener and then turn off the dialog, the method is called in the fragment to add a new mailing address to the list, which then displayed in the ListView, and in this method getActivity () returns null.

I think the fragment has not yet been attached and / or not created, since my breakpoint in onResume () never interrupts execution. But I don’t see a way to make sure that my fragment was created when the listener was called to update the list.

I will be happy to provide additional information, if you have any ideas that can help me here, Google this time did not help :(

+5
source share
1 answer
+4

All Articles