-3

BaseActivity.java

Language switching enter image description here

Intent enter image description here

OnClickListener enter image description here

Error demo

enter image description here

No error message was prompted.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
ChengXi
  • 15
  • 2

1 Answers1

0

You are using old style of language switching which were deprecated and removed after releasing android 8, It completely get removed. However, if you want to use your application for android prior to 26, you have to change your code on language switching Image as follow:

Configuration config = new Configuration(resources.getConfiguration());

New instance of Configuration have to be passed to resources.updateConfiguration();. above line will solve your problem.

On the other hand if you want to publish your application for higher api level, follow link below:

@Override
protected void attachBaseContext(Context newBase){
    Configuration configuration = new Configuration(newBase.getResoureces().getConfiguration());

    configuration.setLocale(/* selected locale which you have to get from user or your app configuration*/);

    super.attachBaseContext(newBase.createConfigurationContext(configuration));
}

Override above method for each activity which you have declared;

Mahdi Rajabi
  • 582
  • 1
  • 4
  • 11