[Android Pro] Android Fragment getActivity返回null解决

  overide FragmentActivity  onSaveInstanceState method like this.

 @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        if(outState != null) {
            String FRAGMENTS_TAG = "android:support:fragments";
            // remove掉保存的Fragment
            outState.remove(FRAGMENTS_TAG);
        }
    }

 

posted @ 2015-10-09 11:31  demoblog  阅读(3590)  评论(0编辑  收藏  举报