android-fragmentsmapactivity

getFragmentManager() returns null, with android.support.v4.app.DialogFragment support libraray


here is the fragment dialog:

import android.support.v4.app.DialogFragment;  
public static class SensorMeasurmentsDialogFragment extends DialogFragment {

    public static SensorMeasurmentsDialogFragment newInstance(int title) {

        SensorMeasurmentsDialogFragment frag = new SensorMeasurmentsDialogFragment();
        Bundle args = new Bundle();
        args.putInt("title", title);
        frag.setArguments(args);
        return frag;

        @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
            .....
        }
    }
}

the call to it is done from a regular activity not from a fragmentActivity because my activity already extends mapActivity.

m_measurmentDlg=SensorMeasurmentsDialogFragment.newInstance(R.string.app_name);
m_measurmentDlg.show(m_measurmentDlg.getFragmentManager(),"measurments");

any idea why is it Null?


Solution

  • The activity must extend from FragmentActivity for you to be able to use Fragments. You might have to use a workaround at the moment until Google updates their map library.

    You might have to use a modified compatibility lib such as this one:

    https://github.com/petedoyle/android-support-v4-googlemaps