title: Navigation Drawer - what does syncState() do and why it should be called inside onPostCreate()?
body: <p>I am learning to create navigation drawer in Android. While reading <a href="https://developer.android.com/training/implementing-navigation/nav-drawer.html" rel="noreferrer">this</a>, I can't understand following code:</p>
  
  <pre><code>@Override
  protected void onPostCreate(Bundle savedInstanceState) {
      super.onPostCreate(savedInstanceState);
      // Sync the toggle state after onRestoreInstanceState has occurred.
      mDrawerToggle.syncState();
  }
  </code></pre>
  
  <p>The documentation says:</p>
  
  <blockquote>
    <p>Synchronize the state of the drawer indicator/affordance with the
    linked DrawerLayout.</p>
    
    <p>This should be called from your Activity's onPostCreate method to
    synchronize after the DrawerLayout's instance state has been restored,
    and any other time when the state may have diverged in such a way that
    the ActionBarDrawerToggle was not notified. (For example, if you stop
    forwarding appropriate drawer events for a period of time.)</p>
  </blockquote>
  
  <p>Further I read about <code>onPostCreate()</code> from sstn's answer <a href="https://stackoverflow.com/questions/24221528/onpostcreate-in-fragment">here</a>: <a href="https://stackoverflow.com/questions/24221528/onpostcreate-in-fragment">OnPostCreate in Fragment</a></p>
  
  <blockquote>
    <p>onPostCreate() is mainly intented for framework use (although you can
    override it). The docs say that it is called after onStart() and
    onRestoreInstanceState().</p>
    
    <p>This might lead to the assumption that it might be called before
    onResume() and thus probably before the message loop is dispatching
    events (including AsyncTask's onPostExecute() method), meaning your
    onPostExecute() will only fire after onPause().</p>
    
    <p>As onPostCreate() is not properly documented and not really intended
    for application use - I might want to say it is not a good idea to
    rely on any observed behaviour.</p>
  </blockquote>
  
  <p>From these two I couldn't understand anything. What does <code>syncState()</code> exactly do and why it should be inside <code>onPostcreate()</code>? Can anyone explain it better?</p>