I know it's possible to have multiple languages in a single application through the res/string and depending on Locale. Here is a case (ANDROID) controling the user language
Now how can I change the language in the phone ? Like I'd do by Menu > Settings > Language & Keyboard > Select locale > languages
Is there some real code to access to these settings ? Or should I create intent for a shortcut to the language settings. Please post some code
Edit : With Locale class developer.android.com/intl/fr/reference/java/util/Locale.html
The constructor is at least Locale(String language) The input is language. How can you retrieve the current language used on the device ?
To make the change persistent, you'll also have to confirm the locale change in the Language preferences screen. You'll find this screen either in the System Settings app: Languages, or System Settings: System: Languages and input. The Language preference screen should contain one entry called “English (Europe)”.
java.util.Locale. A Locale object represents a specific geographical, political, or cultural region. An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to tailor information for the user.
Key-Takeaway #5: To get the list of preferred locales of the device (as defined in the Settings), call Resources. getSystem(). getConfiguration(). getLocales() .
In this step, we are required to create a string resource file for the Hindi language. Go to app > res > values > right-click > New > Value Resource File and name it as strings. Now, we have to choose qualifiers as Locale from the available list and select the language as Hindi from the drop-down list.
Not sure about setting it directly from the app, but if you want to send the user there to change it themselves, try this:
Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClassName("com.android.settings", "com.android.settings.LanguageSettings"); startActivity(intent);
There is another way to open system settings to change the language:
Intent i = new Intent( android.provider.Settings.ACTION_LOCALE_SETTINGS ); startActivity( i );
It shows just the list of languages, and when you choose one - it changes the language on the device.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With