I have been attempting to diagnose this for a while; and I hope to give as
clear of a picture as possible here to figure out how in the world I can
fix this. I have been unable to reproduce this but in the wild I get this
error from our users all the time.
I have an activity that contains a static variable; on destroy it will
clear the value of the static. This particular activity contains 5
actionbar tabs. We handle the configuration ourselves and I have actually
ended up changing it to state that we handle EVERY available option of
android:config. Unfortunately this has not helped one bit. On to what I
am seeing from the stack traces:
The static in the activity that defines the tabs becomes cleared and a null
pointer exception is raised. This only happens on the onDestroy method.
However, it is actually happening when changing tabs but only in some
cases? The fragments themselves utilize this static variable on the
onCreate method of the fragment (which is the main reason for the static).
Here is an example of the file layout:
SiteActivity
-> JournalFragment
-> GuestbookFragment
Build details:
+ Android Fragment Support Library
+ Target SDK: API 13
+ Minimum SDK: API 7
public class SiteActivity extends FragmentActivity {
public static Site currentSite;
@Override
public void onDestroy() {
super.onDestroy();
currentSite = null;
}
}
public class JournalFragment extends Fragment {
@Override
public void onCreate(Bundle sis) {
super.onCreate(sis);
SiteActivity.currentSite.value; // java.lang.NullPointerException
in some cases?
}
}
AndroidManifest.xml value for SiteActivity:
<activity
android:configChanges="orientation|keyboard|keyboardHidden|screenSize|smallestScreenSize|uiMode|fontScale|screenLayout|navigation|touchscreen|locale|mnc|mcc"
android:label="@string/app_name"
android:name=".SiteActivity" >
Any ideas?
--
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