title: Custom Application class: Constructor vs. onCreate()
body: <p>One of my Android apps uses a custom Application class to perform some global initialization. This done in the <code>onCreate()</code> method:</p>
  
  <pre><code>public class MyApplication extends Application {
      @Override
      public void onCreate() {
          super.onCreate();
          someCustomInit();
      }
  }
  </code></pre>
  
  <p>This works fine, but now I have discovers a crash log in the Developer Console which indicated that <code>MyApplication.onCreate()</code> did not run / has not completed at the time the crash happened: The code crashed because some initialization that is performed <code>MyApplication.onCreate()</code> was not complete.</p>
  
  <p><strong>How is this possible?</strong> I assumed that  <code>MyApplication.onCreate()</code> would run before all other code? Isn't that correct?</p>
  
  <p><strong>Is it save to move <code>someCustomInit();</code> to the constructor of <code>MyApplication</code> instead?</strong> No other code should run before the application object has been created, correct?</p>
  
  <p>Or are there any side effects from using the constructor instead of <code>onCreate()</code>?</p>