Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>FINALLY FOUND THE ERROR AND THE PROPER SOLUTION !!</strong></p> <p>Actually, The problem occurred only when people first launched the App from a screen on land mode... The App is forced to be portrait in the Manifest, but, nevertheless, I realised that Android still executes the onConfigurationChanged at launch (when passing from Land to Portrait, e.g)</p> <p>The problem is that the App is in 2 languages and to keep the right language on screen orientation I had increment my own Myapplication (to extend Application) to manage onConfigurationChanged and set the correct Locale default throughout the App!! </p> <p>Even after forcing the App to Portrait in the Manifest (for some reasons some time ago), the onConfigurationChanged from MyApplication.java was still executed in some circomstances...</p> <p><strong>THE PROBLEM</strong> :</p> <p>The code in the MyApplication.java was </p> <pre><code>public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Set correct language (default or chosen) Locale locale = new Locale(getState()); Locale.setDefault(locale); newConfig.locale = locale; getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics()); } </code></pre> <p><strong>THE SOLUTION</strong>:</p> <p>Do not use directly newConfig, but make a Modifiable Configuration object, instead, as adviced by Android Developper, and work with it</p> <pre><code>public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Set correct language (default or chosen) Locale locale = new Locale(getState()); Locale.setDefault(locale); Configuration config = new Configuration(newConfig); // get Modifiable Config from actual config changed config.locale = locale; getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); } </code></pre> <p>The former solution to load directly the newConfog objest was working until Android v2.3 but was not accepted any more in the Android Version >= 4.0</p> <p>EVERYTHING IS OK NOW !!</p> <p>(Special Thanks to Frédéric Espiau alias <a href="http://www.siteduzero.com/membres-294-15848.html" rel="noreferrer">Apollidore</a>, as the solution came reading his excellent book "Créez des applications pour Android")</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload