title: In Activity, is it ever fine to access savedInstanceState before super.onCreate?
body: <p>If we perform rotation, here's is sequence of code execution for Activity and Fragment.</p>
  <ol>
  <li>Activity's <code>super.onCreate()</code></li>
  <li>Fragment's <code>super.onCreate()</code></li>
  <li>Fragment's all custom user code after <code>super.onCreate()</code></li>
  <li>Activity's all custom user code after <code>super.onCreate()</code></li>
  </ol>
  <p>If we have a <code>savedInstanceState</code> restored variable in Activity, being accessed by Fragment, we need to initialize it before Activity's <code>super.onCreate()</code></p>
  <h2>MainActivity</h2>
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      public int variable = 0;
  
      MainFragment mainFragment = null;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // Is it ever Ok to perform accessing to savedInstanceState, before
          // super.onCreate?
          if (savedInstanceState != null) {
              this.variable = savedInstanceState.getInt(&quot;VARIABLE&quot;);
          }
  
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_main);
  
          if (savedInstanceState == null) {
              mainFragment = new MainFragment();
              getSupportFragmentManager().beginTransaction().replace(R.id.content, mainFragment).commit();
          } else {
              mainFragment = (MainFragment) getSupportFragmentManager().findFragmentById(R.id.content);
          }
      }
  
      @Override
      public void onSaveInstanceState(Bundle savedInstanceState) {
          super.onSaveInstanceState(savedInstanceState);
  
          savedInstanceState.putInt(&quot;VARIABLE&quot;, variable);
      }
  }
  </code></pre>
  <hr />
  <h2>MainFragment</h2>
  <pre><code>public class MainFragment extends Fragment {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          android.util.Log.i(&quot;CHEOK&quot;, &quot;In MainFragment, accessing variable from MainActivity -&gt; &quot; + ((MainActivity)getActivity()).variable);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.fragment_main, container, false);
          return view;
      }
  }
  </code></pre>
  <hr />
  <p>However, such technique (Access savedInstanceState before Activity's super.onCreate) is not being mentioned in the official documentation. I was wondering, is it ever Ok to do so? Is there any edge cases I will encounter?</p>