I need to develop an app which on installation onto a Jelly Bean Device will change OS language into Spanish, just that. Run in silent mode, no need to interact with end-user, no need to chose another language or revert the change. Just install the app and change device into Spanish language
I've seen lot of examples on the web but none is working well for me. I know how to run Android Studio and accommodate the code I find but its never working correctly.
Actually I was trying with something like this (but with no success)
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String languageToLoad = "es_ES"; // your language
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,getBaseContext().getResources().getDisplayMetrics());
this.setContentView(R.layout.activity_main);
}
}