Bug 945832 - java.lang.IllegalStateException: No ContextGetter; cannot fetch prefs. on rotation or system locale change. r=wesj

This commit is contained in:
Richard Newman 2013-12-03 15:05:43 -08:00
parent f61459c71b
commit e868ca3700
2 changed files with 11 additions and 3 deletions

View File

@ -16,6 +16,7 @@ import android.content.res.Configuration;
import android.util.Log;
public class GeckoApplication extends Application {
private static final String LOG_TAG = "GeckoApplication";
private boolean mInited;
private boolean mInBackground;
@ -29,8 +30,8 @@ public class GeckoApplication extends Application {
*/
@Override
public void onConfigurationChanged(Configuration config) {
Log.d("GeckoApplication", "onConfigurationChanged: " + config.locale +
", background: " + mInBackground);
Log.d(LOG_TAG, "onConfigurationChanged: " + config.locale +
", background: " + mInBackground);
// Do nothing if we're in the background. It'll simply cause a loop
// (Bug 936756 Comment 11), and it's not necessary.
@ -41,7 +42,13 @@ public class GeckoApplication extends Application {
// Otherwise, correct the locale. This catches some cases that GeckoApp
// doesn't get a chance to.
LocaleManager.correctLocale(getResources(), config);
try {
LocaleManager.correctLocale(getResources(), config);
} catch (IllegalStateException ex) {
// GeckoApp hasn't started, so we have no ContextGetter in LocaleManager.
Log.w(LOG_TAG, "Couldn't correct locale.", ex);
}
super.onConfigurationChanged(config);
}

View File

@ -44,6 +44,7 @@ public class LocaleManager {
private static BroadcastReceiver receiver;
public static void setContextGetter(ContextGetter getter) {
Log.d(LOG_TAG, "Calling setContextGetter: " + getter);
LocaleManager.getter = getter;
}