How was this code executed?
<p>I have the following piece of code. I know that there are errors parsing the data on my server. Regardless of that error how did the MainActivity get started up as a result? </p>

<p>In case it isn't clear. The log shows that the first else statement is run by printing out the messages "I should download your profile" and "I have just saved your profile to your phone" after that somehow it jumps up the to the top to open the MainActivity. I would expect the program to just hang or give me a null pointer exception, not to mention the fact that the method itself is failing due to a JSON parsing error (which is exclusive to this behavior I am asking about now)</p>

<p>PS This code is very much in "draft" form. Before I move forward to finish it I wanted to understand this a bit more. </p>

<pre><code>        // Check login status in database
    userFunctions = new UserFunctions();
    if(userFunctions.doesUserHaveProfile(getApplicationContext())){

        // they have a profile launch the MainActivity
        Intent mainActivity = new Intent(getApplicationContext(), MainActivity.class);
        mainActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(mainActivity);
        // Closing dashboard screen
        finish();

    }else{
        String email = new String("email");
        email = db.getUserName(email);
        //Try and download their profile from the server. 
        userFunctions = new UserFunctions();
        if(userFunctions.doesUserHaveProfileOnServer(email) != null){
            //download it
        System.out.println("I should download your profile now");

        userFunctions.getServerGameState(email, pet, qty, exp);
        db.saveLocalGameSate(pet, qty, exp);
        System.out.println("I just saved your profile to your phone");

        } else{
            //if it doesn't exist make them pick a pet
            Intent dashboardActivity = new Intent(getApplicationContext(), FirstPetActivity.class);
            dashboardActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(dashboardActivity);

        //
        finish();
    }

}
}
</code></pre>

<p>Here is my error code proving that the else statement was run. I would expect a general null exception forse close since there was a parsing error?</p>

<pre><code>05-29 09:31:53.130: I/ActivityManager(103): Starting: Intent { flg=0x4000000 cmp=com.company.pet/.login_library.LoadProfile } from pid 4418
05-29 09:31:53.170: I/WindowManager(103): Setting rotation to 0, animFlags=1
05-29 09:31:53.180: I/ActivityManager(103): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=1/1/2 nav=3/1 orien=1 layout=34 uiMode=17 seq=42}
05-29 09:31:53.330: D/dalvikvm(175): GC_EXTERNAL_ALLOC freed 126K, 52% free 2985K/6215K, external 6056K/6058K, paused 109ms
05-29 09:31:53.430: E/JSON(4418): Invalid Request
05-29 09:31:53.430: E/JSON Parser(4418): Error parsing data org.json.JSONException: Value Invalid of type java.lang.String cannot be converted to JSONObject
05-29 09:31:53.430: I/System.out(4418): I should download your profile now
05-29 09:31:53.590: E/JSON(4418): Invalid Request
05-29 09:31:53.590: E/JSON Parser(4418): Error parsing data org.json.JSONException: Value Invalid of type java.lang.String cannot be converted to JSONObject
05-29 09:31:53.600: I/System.out(4418): I just saved your profile to your phone
05-29 09:31:53.650: I/ActivityManager(103): Starting: Intent { flg=0x4000000 cmp=com.company.pet.gamingengine.MainActivity } from pid 4418
05-29 09:31:53.660: I/WindowManager(103): Setting rotation to 1, animFlags=1
05-29 09:31:53.680: I/ActivityManager(103): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=1/1/2 nav=3/1 orien=2 layout=34 uiMode=17 seq=43}
05-29 09:31:53.800: V/ARData(4418): Setting DIRTY flag!
05-29 09:31:53.820: W/System.err(4418): java.lang.NullPointerException
05-29 09:31:53.820: W/System.err(4418):     at com.company.pet.gamingengine.MainActivity.updateData(MainActivity.java:132)
05-29 09:31:53.820: W/System.err(4418):     at com.company.pet.gamingengine.MainActivity.updateDataOnZoom(MainActivity.java:109)
</code></pre>
