Not sure if this helps, but use http://developer.android.com/reference/java/lang/System.html#identityHashCode(java.lang.Object) to check whether the Application object is indeed the same in both cases (or whether they are in different DVMs)
On Apr 20, 12:04 pm, patbenatar <patbena...@gmail.com> wrote: > Bob- > > Nope, I'm using getApplication() > > For instance [inside an Activity]: > > MyApplication application; > > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > application = (MyApplication) this.getApplication(); > > } > > The error is most easily re-produceable when I am in Activity B, after > A started it for result, and then click a button in B to launch Maps > with an Intent to search for an address, then from Maps I hit Home > then my launcher icon on my Home Screen to go back into my app--BAM! > Activity B fails onResume with a NullPointerException coming from a > getter method on my MyApplication class, when I know for sure Activity > A properly set the data in MyApplication.. > > So strange... > > Thanks, > Nick > > On Apr 20, 2:18 am, Bob Kerns <r...@acm.org> wrote: > > > > > > > I do this, without any issues at all. > > > How are you getting your Application instance from your activities? > > not getApplicationContext() I hope... > > > Have you examined the state from the debugger? There may be something > > you're missing about the state of things. > > > On Apr 19, 11:41 pm, patbenatar <patbena...@gmail.com> wrote: > > > > Hey all- > > > > I am using an Application object to store app-wide instance data--data > > > that I need to remain in existence for the entire lifetime of the app, > > > so the Application class seems like the proper place to put it. I have > > > just finished reading this > > > threadhttp://groups.google.com/group/android-developers/browse_thread/threa... > > > that goes into pretty good detail and receives confirmation from > > > Googler hackbod as to how the Application class performs--and from > > > that info it seems this strange behavior I am receiving should not be > > > happening... > > > > Basically, every once in a while when I resume my app in any of its > > > Activities (it is still running in memory so onCreate is not called) I > > > get NullPointerExceptions because instance variables in my Application > > > class are returning null when I request them from my Activity (via a > > > getter method in my custom Application class). It seems as if > > > sometimes Android saves the states of my Activities but deletes all my > > > instance variable data... This can't be an Android problem--there must > > > be something wrong with my code. > > > > Has anyone else ever ran into an issue of this kind? Any ideas as to > > > what may be causing this? I'm not going to post my code here as that > > > won't help anyone, but hopefully someone can point me in some helpful > > > directions. > > > > Thanks so much, > > > Nick > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Android Developers" group. > > > To post to this group, send email to android-developers@googlegroups.com > > > To unsubscribe from this group, send email to > > > android-developers+unsubscr...@googlegroups.com > > > For more options, visit this group > > > athttp://groups.google.com/group/android-developers?hl=en > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to android-developers@googlegroups.com > > To unsubscribe from this group, send email to > > android-developers+unsubscr...@googlegroups.com > > For more options, visit this group > > athttp://groups.google.com/group/android-developers?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group > athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en