When starting a new Activity, I want to pass a complex object and do
so by using this approach:
MyActivity.COMPLEX_OBJ = myComplexObj; // which is definitely NOT
NULL!
Intent intent = new Intent();
intent.setClass(this, MyActivity.class);
startActivity(intent);
and then in MyActivity:
@Override
public void onCreate(Bundle bundle) {
if (COMPLEX_OBJ == null) {
// report to Flurry
...
}
...
}
When I've tested this on my devices, everything works fine.
However, from Flurry analytics, I see that COMPLEX_OBJ is sometimes
null! But I've checked my code 100 times and can say it is absolutely
not possible that COMPLEX_OBJ is being set with a non null value.
My initial guess was that onCreate() was being called before
startActivity() - is this possible? BTW, the activity is defined in
the Manifest without any intent filters.
Then I found this:
http://developer.android.com/intl/de/guide/appendix/faq/framework.html#3
which says:
"But, the life cycle of a static is not well under your control"
I thought if I set a static field then that will stay set as long as
the VM is alive. Or have a misunderstood something?
--
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