On Tue, Jul 17, 2012 at 6:48 AM, xoom <ei.rtsp.x...@gmail.com> wrote:
> Actually when I clear the RAM from task manager it clears all the memory of
> my application including some global variables shared between the
> activities. And when the activity restarts I am getting null pointer
> exceptions because this global variables are getting cleared. One way is to
> store the application state in bundle but is there any other way?
>
> If my whole application is closed then its fine, no need to preserve the
> application state also.

Your "whole application is closed" in all cases you have cited here.
Your process is being terminated by the task manager, as you can tell
by the fact that your global variables have been cleared.

Your problem is that you are assuming that those global variables
always exist and that users are always coming into your application
through one path that sets up those variables. That is not necessarily
a valid assumption -- recent tasks is just one example of a way the
user can "deep link" elsewhere in your application. One way or
another, you need to handle the case where users return to your app,
running in a fresh process, but are not coming into your launcher
activity.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.8 Available!

-- 
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

Reply via email to