Since I had some problems implementing Parcelable, and I'm currently very short of time, and also wanted to avoid parcelation overload, I decided to pass lists, between activities, using static fields of the application. For primitive values and objects which are easily serializable (making them implement Serializable) I pass using a bundle, like usual.
Now I distributed a test app and got, in my error reports, a high amount of crashes, because of null pointer exceptions calling methods on the objects stored in these fields. I implemented them very cleanly, I use variables like: public static final List<String> paramsListFromAToB; And Activity B is always started just by Activity A, and I set the parameter exactly in the same place where I fill the other bundle data, and I read it in B exactly in the same place, where I read the bundle data received from A. I of course checked very carefully if the lists, for some reason, are null before being passed, but this can't be the case, because I'm initializing right before the line and it's impossible it can become null, there's also no other thread using it. I'm developing for API 7. Now comes the second part of the description, which might be enlightening for someone. A while ago I had myself this problem very repeatedly, and found the reason. I was because when activity B loaded, and initalized the layout, it ran out of memory, because of bitmaps. I saw in the log an out of memory exception, then a message that the virtual machine is exiting, and then, for some reason, the following code was excecuted (but in a very strange way, because, if I put breakpoint for example to try to debug, it didn't stop there), but with the static fields of the Application being null, probably, because the VM shutted down, so this object was not available anymore. The strange thing is that, that time, I always got an out of memory exception before. Now I only found 1 out of memory exception in the error traces, but 7 null pointer exceptions because of the static objects being null. Ok, so what is causing this? Is it still running out of memory, if yes, why am I not getting out of memory exception before? If not, what else can shut down the VM / make this fields null unexpectedly? Very thankful in advance for every answer and advice. This is really urgent, have to launch this soon and can't release this way, it's crashing very frequently... don't know how to fix it. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

