Activity is blinking after locale change in Android 4.1+

后端 未结 1 1899
不思量自难忘°
不思量自难忘° 2021-01-06 09:30

I have implemented custom locale selection about a year ago but after 4.1 release users start to complain on constant activity blinking. Here is code I\'m using (compiled fr

相关标签:
1条回答
  • 2021-01-06 09:46

    This line caused solution to fail:

    getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());
    

    Correct (at least it works) implementation is defined here https://stackoverflow.com/a/14010044/554336 :

    Configuration config = new Configuration();
    config.locale = locale;
    getResources().updateConfiguration(config, getResources().getDisplayMetrics());
    

    So new configuration instance should be created every time.

    0 讨论(0)
提交回复
热议问题