I have all activities inherit from my BaseActivity. It's been working great for a year. Now after I upgraded my Nexus S to 4.0.3 my app stopped working - I get infinite loop that look like so:
12-28 20:09:22.285: DEBUG/IDATT.HomeActivity(24662): onCreate
12-28 20:09:22.285: DEBUG/IDATT.BaseActivity(24662): onCreate
12-28 20:09:22.442: DEBUG/IDATT.HomeActivity(24662): onResume
12-28 20:09:22.442: DEBUG/IDATT.BaseActivity(24662): onResume
12-28 20:09:22.578: DEBUG/IDATT.HomeActivity(24662): onCreate
12-28 20:09:22.578: DEBUG/IDATT.BaseActivity(24662): onCreate
12-28 20:09:22.653: DEBUG/IDATT.HomeActivity(24662): onResume
12-28 20:09:22.653: DEBUG/IDATT.BaseActivity(24662): onResume
12-28 20:09:22.785: DEBUG/IDATT.HomeActivity(24662): onCreate
12-28 20:09:22.785: DEBUG/IDATT.BaseActivity(24662): onCreate
12-28 20:09:22.863: DEBUG/IDATT.HomeActivity(24662): onResume
12-28 20:09:22.863: DEBUG/IDATT.BaseActivity(24662): onResume
So, when HomeActivity
started it calls base.onCreate which is second line.
Then onResume
called and for some reason after that - BaseActivity.onCreate called again.
Does this make sense? One thing I noticed is that everything runs OK until I turn screen. Then it starts blinking. Even if I hit Home and open application again. But if I kill process and restart it looks good until I try to flip screen again..
EDIT: I removed all the code samples - they not relevant.
Seems like I found my issue. I did override onConfigurationChange
in my Application
@Override
public void onConfigurationChanged(Configuration newConfig)
{
Log.d(LOG_TAG, "onConfigurationChanged");
super.onConfigurationChanged(newConfig);
//reset locale to our defined locale in settings
// String l = Preferences.getLocale(getApplicationContext());
// Locale locale = new Locale(l);
// if (!l.equals(""))
// {
// newConfig.locale = locale;
// Locale.setDefault(locale);
// getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());
// }
}
Commented code caused issue. Seems like doing what I did (to change locale) caused whole UI to restart and it was doing it repeatedly. Now I need to come up with better way.
So, there is breaking change in this Locale area in 4.0