Change language settings (locale) for the device

前端 未结 5 1438
北恋
北恋 2020-11-29 03:42

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 langua

相关标签:
5条回答
  • 2020-11-29 04:01

    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.

    0 讨论(0)
  • 2020-11-29 04:07

    I found another answer to my own question. There is an open source code project code.google.com/p/languagepickerwidget It's recreating a ListActivity to display and pick the languages.

    Jim , your solution is much simple and exactly what I needed. It's a shorcut to the settings. Immediately after you published, I uploaded an app called "raygional" on the market. If I could (I only have 6 points) I'd make your answer useful.

    There is another way to see the processes and intents. On the emulator go to Menu > Dev Tools > Development Settings > and click on Show running processes

    0 讨论(0)
  • 2020-11-29 04:10

    To expand on Jim's answer if you change the intent to:

    intent.setClassName("com.android.settings", "com.android.settings.LocalePicker"); 
    

    It will drop the user off directly in the language selection list and once a language is selected it will return to your application.

    It removes a click, doesn't make the user think about which of the three (language, dictionary, and keyboard) options to choose and returns to your app immediately after selection.

    0 讨论(0)
  • 2020-11-29 04:18

    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);
    
    0 讨论(0)
  • 2020-11-29 04:26

    As far as I know, the only way to change the Locale of the device without using Intents (what the other solutions propose) is accessing internal classes through reflection (with the risks that this implies).

    You can find an exact example for this use case here: http://www.tutorialforandroid.com/2010/07/access-internal-classes-in-android.html

    0 讨论(0)
提交回复
热议问题