tags:

views:

26

answers:

2

Ok i have an application with 2 different languages (english and german), how to change them from my application? When i click the Language button im using intent to com.android.settings.LocalePicker and from there i select the language. So instead of that i want to select English and German options from dialog box. I know how to create the dialog box, but don't know how to change the locale.

+2  A: 

Application resources are fetched using the system local which isn't changeable from within an application.

The system settings screen uses a class (ActivityManagerNative) which isn't available via the SDK and thus can not be guaranteed to work between releases, and hence shouldn't be used in your code.

So your options are;

  • Don't offer the functionality in your app
  • Implement your own system for determining what setting the user has selected in your app and pulling the appropriate resources using your own code.
Al Sutton
A: 

You can do this : 1. create a normal android dialog with radio button selection of English & German 2. OnCheckedChange ()

write this to change the Language Locale myLocale = new Locale(/String selected/); Locale.setDefault(myLocale );

Configuration config2 = new Configuration(); config2.locale = myLocale ; getBaseContext().getResources().updateConfiguration(config2, getBaseContext().getResources().getDisplayMetrics());

Faheem