1

I have 2 fragments, a fragment with a MapFragment and a regular details fragment.

I followed the guide by arshu here : How to put Google Maps V2 on a Fragment Using ViewPager

But when I rotate my screen in the mapFragment in get an error 'Can not perform this action after onSaveInstance'.

This is probaly caused by the onDestroyView method

super.onDestroyView();
    if (mMap != null) {
        getActivity()
                .getSupportFragmentManager()
                .beginTransaction()
                .remove(getActivity().getSupportFragmentManager()
                        .findFragmentById(R.id.location_map)).commit();
        mMap = null;
    }

But if I remove this, I get following error:

Error inflating class fragment at CreateViewFromTag

Full code here: https://github.com/RobbySmet/ITPAppChallenge

How can I fix this or what am I doing wrong?

Community
  • 1
  • 1
Robby Smet
  • 4,649
  • 8
  • 61
  • 104

1 Answers1

0

You cannot commit a fragment transaction in ondestroy. Put your code in your onpause method instead.

Illegal Argument
  • 10,090
  • 2
  • 44
  • 61