2

In application the language doesn't change completely. I select English. It say English. But when I go to another activity. The language change to primitive language. After I go to the main activity. The language is primative language. But when I click English or French(again) not any problem at all.

I think I didn't tell well. I hope you can understand well with video :

https://drive.google.com/file/d/1-5QL_5kdzg8d7QDe8UF8cwVii_-1S4JR/view?usp=sharing

The code for changing language :

public void dilidegistir(String dil){

            Resources activityRes = getResources();
            Configuration activityConf = activityRes.getConfiguration();
            Locale newLocale = new Locale(dil);
            activityConf.setLocale(newLocale);
            activityRes.updateConfiguration(activityConf, activityRes.getDisplayMetrics());

            Resources applicationRes = getApplicationContext().getResources();
            Configuration applicationConf = applicationRes.getConfiguration();
            applicationConf.setLocale(newLocale);
            applicationRes.updateConfiguration(applicationConf,
                    applicationRes.getDisplayMetrics());

            finish();
            startActivity(getIntent());

}

How can I solve this problem?

I need your help.

Thiers
  • 23
  • 7
  • follow this, might help https://stackoverflow.com/a/46024733/6668339 – Hassan M Ashraful Jul 09 '19 at 11:43
  • @HassanM.Ashraful can share the code context wraper – Thiers Jul 09 '19 at 16:02
  • @Thiers - I don't know why you're trying to change the language at runtime (normally it should be handled on the system level based on device's settings), but if you really need it check out this article: https://proandroiddev.com/change-language-programmatically-at-runtime-on-android-5e6bc15c758 I hope it's helpful. – Dawid Sibiński Jul 13 '19 at 14:15

1 Answers1

0

I don't know why you're trying to change the language at runtime (normally it should be handled on the system level based on device's settings), but if you really need it check out this article: https://proandroiddev.com/change-language-programmatically-at-runtime-on-android-5e6bc15c758

I hope it's helpful.

Dawid Sibiński
  • 1,657
  • 3
  • 21
  • 40