Application getInstance returning null
<p>I'm facing a problem that i can figure it out.</p>

<p>My Application</p>

<pre><code>public class AppApplication extends Application {

    public static AppApplication sInstance;

    public static User mUser;

    public static AppApplication getInstance() {
        return sInstance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Fabric.with(this, new Crashlytics());

        sInstance = this;
        mUser = restoreUserFromSession();

        ReportUtils.getsInstance(this).resendCachedReport();

    }
    /**
     * Restore logged user stored on session
     * @return
     */
    public User restoreUserFromSession(){
        return UserSession.getInstance(this).restoreUser();
    }
}
</code></pre>

<p>My Manifest</p>

<pre><code>&lt;application
        android:name=".AppApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" &gt;
.
.
.
&lt;/application&gt;
</code></pre>

<p>In my Fragment I have that functino</p>

<pre><code>public void doLogin(RestParams params) {
        RestClient.getApi(getActivity(), getActivity()).doLogin(params.getParams(), new RestCallback&lt;LoginApi&gt;() {
            @Override
            public void failure(RestError restError) {
                hideProgress();
                LOGI(TAG, restError.getStrMessage());
                DialogUtils.getInstance().showOkDialog(getActivity(),
                        getString(R.string.str_warning),
                        restError.getStrMessage());
            }

            @Override
            public void successApi(final LoginApi loginApi, Response response) {
                loginApi.data.email = mEditEmail.getText().toString();

                if(AppApplication.getInstance() != null) {
                    AppApplication.getInstance().saveUserSession(loginApi.data);
                } else {
                    Handler handler = new Handler();
                    handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            AppApplication.getInstance().saveUserSession(loginApi.data);
                            LogUtils.setCrashUser(loginApi.data.name);
                        }
                    }, 1000);
                }
                mListener.goToMain();

                GcmUtils gcm = new GcmUtils(getActivity(), getActivity());
                gcm.registerInBackground();
            }
        });
    }
</code></pre>

<p>And my problem is when I launch the app for the fist time, the AppApplication.getInstance() return null, when I open the app again, every thing works fine, I have no idea what is wrong.</p>

<p><strong>----EDITED----</strong></p>

<p>My problem is that the first time the Activity's onCreate is called before Application's onCreate, that happens only in Nexus 9 - API 23 so far.</p>

<p>Obs: When I run in debug mode, it does not happen</p>