getting exception “IllegalStateException: Can not perform this action after onSaveInstanceState”

前端 未结 30 2810
迷失自我
迷失自我 2020-11-22 05:12

I have a Live Android application, and from market i have received following stack trace and i have no idea why its happening as its not happening in application code but it

30条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 06:04

    My solution for that problem was

    In fragment add methods:

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        ...
        guideMapFragment = (SupportMapFragment)a.getSupportFragmentManager().findFragmentById(R.id.guideMap);
        guideMap = guideMapFragment.getMap();
        ...
    }
    
    @Override
    public void onDestroyView() {
        SherlockFragmentActivity a = getSherlockActivity();
        if (a != null && guideMapFragment != null) {
            try {
                Log.i(LOGTAG, "Removing map fragment");
                a.getSupportFragmentManager().beginTransaction().remove(guideMapFragment).commit();
                guideMapFragment = null;
            } catch(IllegalStateException e) {
                Log.i(LOGTAG, "IllegalStateException on exit");
            }
        }
        super.onDestroyView();
    }
    

    May be bad, but couldn't find anything better.

提交回复
热议问题