views:

2196

answers:

3

Hi, 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 http://stackoverflow.com/questions/2078289/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 ?

A: 

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);
Jim Blackler
Hey Jim, thanks very much.Just another question , how did you know about the package name and class name for settings ?
raychenon
What I did is to use my phone while connected to my PC on USB, and look at the logcat output. Every Intent started is logged to the output. The line read I/ActivityManager( 1018): Starting activity: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.LanguageSettings } On a hunch I went onto Google Code Search and searched for "LanguageSettings Android Intent" and found an example of someone doing just this. I tested it myself and simplified the code for a snippet here.
Jim Blackler
I found another answer to my own question.There is an open source code projecthttp://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 .
raychenon
That's great Ray, I'll check out your app some time.
Jim Blackler
A: 

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

raychenon
A: 

I was sold an Android 'phone in Portuguese instead of English. I had to send it back. My first and last Android 'phone :) Oops. I know that this does not help a lot.

Ciao