Application class data being nulled out when switching to Camera Intent
<p>I'm working on an app that uses a custom class with other custom classes as members. ie:</p>

<pre><code>public class TopClass {
    public OtherClass1 otherClass1;
    public OtherClass2 otherClass2;
}
</code></pre>

<p>This data needs to be available to several other Activities. I had been storing this in the main Activity of the app and was able to reference it.</p>

<p>Everything is working great except when running on a Droid X2. On that device it will run fine - until an external Intent is called. The same thing happens when switching to the Camera, Maps, or Calendar Intents: after returning to the app with either the back button or, in the case of camera, the "OK" button the app will FC with NPE referencing the "TopClass"</p>

<p>Here is an example of the camera call for reference:</p>

<pre><code>public void startCamera(int pos) {
    Log.v(App.DEBUG_TAG, "startCamera(slot "+pos+")");

    Intent i = new Intent("android.media.action.IMAGE_CAPTURE");
    i.putExtra(MediaStore.EXTRA_OUTPUT, getFilesDir().getAbsolutePath());
    i.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivityForResult(i, pos);
}
</code></pre>

<p>I switched to using an Application class to store the "TopCLass", but no change.</p>

<p>Using ACRA to get the stack traces and logcat where I've started logging every lifecycle event in the Activities I can see that the "TopClass" is null upon returning to the Activity. All of the local variables for the last Activity still exist in unchanged states, just the 'global' data has been nullified - GC'd, I am guessing.</p>

<p>I can't duplicate this on my device (Droid Incredible running CM7 [2.3.7]), or any emulator - not even the X2 addon, nor on my wife's Droid X.</p>

<p>I'm trying an experiment where I copy the 'global' "TopClass" to a local "TopClass" variable, but haven't heard back on whether or not that has worked yet.</p>

<p>My questions are:</p>

<ol>
<li><p>What would be the proper or recommended way of persisting this data? From my reading I gathered that it was to use an Application class instance, but that isn't working.</p></li>
<li><p>Any ideas why the X2 is nulling out the Application-owned classes when calling an external Intent?</p></li>
</ol>
