Best code examples for Android Configuration class (android.content.res.Configuration)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Configuration class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android Configuration examples from Open Source projects
This code example shows how to use the following methods:
    private Configuration configuration;
    private ShadowConfiguration shConfiguration;
 
    @Before 
    public void setUp() throws Exception { 
        configuration = new Configuration();
        shConfiguration = Robolectric.shadowOf( configuration );
    } 
 
    @Test 
    public void testSetToDefaults() throws Exception { 
        configuration.setToDefaults();
        assertThat(configuration.screenLayout).isEqualTo(Configuration.SCREENLAYOUT_LONG_NO | Configuration.SCREENLAYOUT_SIZE_NORMAL);
    } 
     
    @Test 
    public void testSetLocale() { 
    	shConfiguration.setLocale( Locale.US );
        assertThat(configuration.locale).isEqualTo(Locale.US);
 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: updateConfiguration
This code example shows how to use the following methods: updateConfiguration
This code example shows how to use the following methods:
    @Test 
    public void testGetAndSetConfiguration_SameInstance() throws Exception { 
        Activity activity = new Activity();
        Resources resources = activity.getResources();
        assertSame(resources.getConfiguration(), resources.getConfiguration());
        Configuration diffConfig = new Configuration();
        shadowOf(resources).setConfiguration(diffConfig);
        assertSame(diffConfig, resources.getConfiguration());
    } 
 
    @Test(expected = Resources.NotFoundException.class) 
    public void testGetDrawableNullRClass() throws Exception { 
        ResourceLoader resourceLoader = new EmptyResourceLoader();
        resources = new Resources(null, null, null);
        ShadowResources.bind(resources, resourceLoader);
 
        assertThat(resources.getDrawable(-12345)).isInstanceOf(BitmapDrawable.class);
    } 
 
    /** 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods:
    } 
 
    private void setLocale(String code) {
        Locale locale = new Locale(code);
        Locale.setDefault(locale);
        Configuration config = new Configuration();
        config.locale = locale;
        mResources.updateConfiguration(config, mResources.getDisplayMetrics());
    } 
 
    private void assertResource(int resId, boolean ewo, boolean ew) throws Throwable {
        boolean expected = mWithOverlay ? ew : ewo;
        boolean actual = mResources.getBoolean(resId);
        assertEquals(expected, actual);
    } 
 
    private void assertResource(int resId, String ewo, String ew) throws Throwable {
        String expected = mWithOverlay ? ew : ewo;
        String actual = mResources.getString(resId);
        assertEquals(expected, actual);
Full Snippet Info
7
CodeRank
Related Android Configuration Questions & Answers:
Other Android Configuration Examples
7:				builder.setOAuthConsumerKey(TWITTER_CONSUMER_KEY);
8:				builder.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET);
9:				Configuration configuration = builder.build();
10:				
11:				TwitterFactory factory = new TwitterFactory(configuration);

Read More

138:	
139:		@Override
140:		public void onConfigurationChanged(Configuration newConfig) {
141:			super.onConfigurationChanged(newConfig);
142:			// Pass any configuration change to the drawer toggls

Read More

221:	
222:		@Override
223:		public void onConfigurationChanged(Configuration newConfig) {
224:			super.onConfigurationChanged(newConfig);
225:			// Pass any configuration change to the drawer toggls

Read More

See Code Examples for Android Configuration Methods: