@Test public void testApplyOverrideConfiguration() { if (Build.VERSION.SDK_INT >= 17) { final int realDensity = mContext.getResources().getConfiguration().densityDpi; final int expectedDensity = realDensity + 1; ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper( mContext, SYSTEM_DEFAULT_THEME); Configuration overrideConfig = new Configuration(); overrideConfig.densityDpi = expectedDensity; contextThemeWrapper.applyOverrideConfiguration(overrideConfig); Configuration actualConfiguration = contextThemeWrapper.getResources().getConfiguration(); assertEquals(expectedDensity, actualConfiguration.densityDpi); } }
public void applyOverrideConfiguration(Configuration overrideConfiguration) { if (mResources != null) { throw new IllegalStateException( "getResources() or getAssets() has already been called"); } if (mOverrideConfiguration != null) { throw new IllegalStateException("Override configuration has already been set"); } mOverrideConfiguration = new Configuration(overrideConfiguration); }
ContextThemeWrapper extends ContextWrapper { public void applyOverrideConfiguration(Configuration overrideConfiguration) { if (mResources != null) { throw new IllegalStateException( "getResources() or getAssets() has already been called"); } if (mOverrideConfiguration != null) { throw new IllegalStateException("Override configuration has already been set"); } mOverrideConfiguration = new Configuration(overrideConfiguration); } }
ContextThemeWrapper extends ContextWrapper { public void applyOverrideConfiguration(Configuration overrideConfiguration) { if (mResources != null) { throw new IllegalStateException( "getResources() or getAssets() has already been called"); } if (mOverrideConfiguration != null) { throw new IllegalStateException("Override configuration has already been set"); } mOverrideConfiguration = new Configuration(overrideConfiguration); } ContextThemeWrapper();  ContextThemeWrapper(Context base, @StyleRes int themeResId);  ContextThemeWrapper(Context base, Resources.Theme theme); }
ContextThemeWrapper extends ContextWrapper { public void applyOverrideConfiguration(Configuration overrideConfiguration) { if (mResources != null) { throw new IllegalStateException( "getResources() or getAssets() has already been called"); } if (mOverrideConfiguration != null) { throw new IllegalStateException("Override configuration has already been set"); } mOverrideConfiguration = new Configuration(overrideConfiguration); } ContextThemeWrapper();  ContextThemeWrapper(Context base, @StyleRes int themeResId);  ContextThemeWrapper(Context base, Resources.Theme theme); void applyOverrideConfiguration(Configuration overrideConfiguration); @Override Resources getResources(); @Override void setTheme(int resid); int getThemeResId(); @Override Resources.Theme getTheme(); @Override Object getSystemService(String name); @Override AssetManager getAssets(); }
ContextThemeWrapper extends ContextWrapper { public void applyOverrideConfiguration(Configuration overrideConfiguration) { if (mResources != null) { throw new IllegalStateException( "getResources() or getAssets() has already been called"); } if (mOverrideConfiguration != null) { throw new IllegalStateException("Override configuration has already been set"); } mOverrideConfiguration = new Configuration(overrideConfiguration); } ContextThemeWrapper();  ContextThemeWrapper(Context base, @StyleRes int themeResId);  ContextThemeWrapper(Context base, Resources.Theme theme); void applyOverrideConfiguration(Configuration overrideConfiguration); @Override Resources getResources(); @Override void setTheme(int resid); int getThemeResId(); @Override Resources.Theme getTheme(); @Override Object getSystemService(String name); @Override AssetManager getAssets();  }