Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>changeLanguage(this);</code> only needs to be called when the language has changed or when the App is loaded.. <code>res.updateConfiguration(conf, dm);</code> updates the global config and is specific to your app instance not your activity instance. </p> <p>When you change the <code>locale</code> in an <code>Activity</code> you have to recreate that <code>Activity</code> to see your language change. This can be easily done by forcing an orientation change then forcing it back like this:</p> <pre><code>setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); </code></pre> <p>If you hit back after a language change you will see the old language because <code>onCreate</code> is not called. You will have to detect in <code>onResume</code> that the language changed and force a recreate of the <code>Activity</code>.</p> <p>-= EDIT =-</p> <p>Using Screen Orientation to reload the <code>Activity</code> has proven to be a bit buggy on some devices. I am now using this to reload the current <code>Activity</code>:</p> <pre><code>public static void resetScreen(Activity activity) { if (activity != null) { if (Build.VERSION.SDK_INT &gt;= 11) { activity.recreate(); } else { Intent intent = activity.getIntent(); activity.overridePendingTransition(0, 0); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); activity.finish(); activity.overridePendingTransition(0, 0); activity.startActivity(intent); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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