Re: [android-developers] Re: selecting language from within the app rather than by locale of the system settings
Hi Menion, Yes, you have to set the locale in onCreate. It was written in the comments of the article. BR, Adrian Vintu http://adrianvintu.com On Thu, Mar 4, 2010 at 6:33 AM, Menion menion.as...@gmail.com wrote: Hi Adrian, thanks for you response. Your code is very similar to mine. Only base diference is that you use Activity.getBaseContext().getResources() instead of mine used Activity.getResources(). But this not help with my main problem. Probably in your code, every display rotate call same INFO/ActivityManager(1160): Config changed: { scale=1.0 imsi=230/3 loc=en_GB touch=3 keys=2/1/1 nav=2/1 orien=2 layout=34} and after that, locale change to default. but is seems that only solution is to call language change code in every onCreate() in every activity. Little bit weird but cannot find any other permanent solution. On Mar 3, 10:38 pm, Adrian Vintu adrianvi...@gmail.com wrote: Hope this will helphttp:// adrianvintu.com/blogengine/post/Force-Locale-on-Android.aspx BR, Adrian Vintu http://adrianvintu.com On Sat, Feb 27, 2010 at 3:09 PM, Menion menion.as...@gmail.com wrote: Hi mot12, sorry not post earlier. I don't know, if you find my info still useful ..., but ad 1) Yes, it's my own function that check if user selected Czech or English, so this return cz or en String. ad 2) I didn't tried this. When user change locale in PreferenceScreen, I force him to restart application. Changing of application language is not a common activity, so restart is not a bad solution I think :). But with your problem, it's relevant to my another problem. Did you try set another locale (language) and then rotate display? With my current solution, ActivityManager send this event INFO/ActivityManager(1160): Config changed: { scale=1.0 imsi=230/3 loc=en_GB touch=3 keys=2/1/1 nav=2/1 orien=2 layout=34} and language of whole application set from my (e.g. cz, to default (in this case to loc=en_GB). I think that this is similar to your problem. Grr ... Hope we find any solution ... On Feb 14, 11:45 am, mot12 martin.hu...@gmail.com wrote: Menion, Ok, now I feel silly because I thought I could figure it out from your post. 1) Settings.getLanguage() is from your own preference settings? It is no android.provider.Settings, right? 2) When my app loads, I read the language preference from my own app preference settings and set the locale using the code you gave. Works great. But if I change the language preference in my settings using updateConfiguration, I hoped I would trigger the onConfigurationChanged of my main Activity. But that doesn't happen despite my entries android:configChanges=locale for the main activity and uses-permission android:name=android.permission.CHANGE_CONFIGURATION/ in the manifest. Let's say I am in the main activity. I load the locale specified in the settings in OnCreate. Everything is great. Now I go from there to a preference activity, change the desired locale, update the configuration via updateConfiguration and using the 'back' key I go back to my main activity. Instead of onConfigurationChanged I get onResume, giving me no possibility to reload my resources. Any idea? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: selecting language from within the app rather than by locale of the system settings
next time, I'll try to read comments also :). Thank you very much, you point me to finally working solution. On Mar 4, 11:41 am, Adrian Vintu adrianvi...@gmail.com wrote: Hi Menion, Yes, you have to set the locale in onCreate. It was written in the comments of the article. BR, Adrian Vintu http://adrianvintu.com On Thu, Mar 4, 2010 at 6:33 AM, Menion menion.as...@gmail.com wrote: Hi Adrian, thanks for you response. Your code is very similar to mine. Only base diference is that you use Activity.getBaseContext().getResources() instead of mine used Activity.getResources(). But this not help with my main problem. Probably in your code, every display rotate call same INFO/ActivityManager(1160): Config changed: { scale=1.0 imsi=230/3 loc=en_GB touch=3 keys=2/1/1 nav=2/1 orien=2 layout=34} and after that, locale change to default. but is seems that only solution is to call language change code in every onCreate() in every activity. Little bit weird but cannot find any other permanent solution. On Mar 3, 10:38 pm, Adrian Vintu adrianvi...@gmail.com wrote: Hope this will helphttp:// adrianvintu.com/blogengine/post/Force-Locale-on-Android.aspx BR, Adrian Vintu http://adrianvintu.com On Sat, Feb 27, 2010 at 3:09 PM, Menion menion.as...@gmail.com wrote: Hi mot12, sorry not post earlier. I don't know, if you find my info still useful ..., but ad 1) Yes, it's my own function that check if user selected Czech or English, so this return cz or en String. ad 2) I didn't tried this. When user change locale in PreferenceScreen, I force him to restart application. Changing of application language is not a common activity, so restart is not a bad solution I think :). But with your problem, it's relevant to my another problem. Did you try set another locale (language) and then rotate display? With my current solution, ActivityManager send this event INFO/ActivityManager(1160): Config changed: { scale=1.0 imsi=230/3 loc=en_GB touch=3 keys=2/1/1 nav=2/1 orien=2 layout=34} and language of whole application set from my (e.g. cz, to default (in this case to loc=en_GB). I think that this is similar to your problem. Grr ... Hope we find any solution ... On Feb 14, 11:45 am, mot12 martin.hu...@gmail.com wrote: Menion, Ok, now I feel silly because I thought I could figure it out from your post. 1) Settings.getLanguage() is from your own preference settings? It is no android.provider.Settings, right? 2) When my app loads, I read the language preference from my own app preference settings and set the locale using the code you gave. Works great. But if I change the language preference in my settings using updateConfiguration, I hoped I would trigger the onConfigurationChanged of my main Activity. But that doesn't happen despite my entries android:configChanges=locale for the main activity and uses-permission android:name=android.permission.CHANGE_CONFIGURATION/ in the manifest. Let's say I am in the main activity. I load the locale specified in the settings in OnCreate. Everything is great. Now I go from there to a preference activity, change the desired locale, update the configuration via updateConfiguration and using the 'back' key I go back to my main activity. Instead of onConfigurationChanged I get onResume, giving me no possibility to reload my resources. Any idea? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: selecting language from within the app rather than by locale of the system settings
My pleasure :) BR, Adrian Vintu http://adrianvintu.com On Thu, Mar 4, 2010 at 6:53 PM, Menion menion.as...@gmail.com wrote: next time, I'll try to read comments also :). Thank you very much, you point me to finally working solution. On Mar 4, 11:41 am, Adrian Vintu adrianvi...@gmail.com wrote: Hi Menion, Yes, you have to set the locale in onCreate. It was written in the comments of the article. BR, Adrian Vintu http://adrianvintu.com On Thu, Mar 4, 2010 at 6:33 AM, Menion menion.as...@gmail.com wrote: Hi Adrian, thanks for you response. Your code is very similar to mine. Only base diference is that you use Activity.getBaseContext().getResources() instead of mine used Activity.getResources(). But this not help with my main problem. Probably in your code, every display rotate call same INFO/ActivityManager(1160): Config changed: { scale=1.0 imsi=230/3 loc=en_GB touch=3 keys=2/1/1 nav=2/1 orien=2 layout=34} and after that, locale change to default. but is seems that only solution is to call language change code in every onCreate() in every activity. Little bit weird but cannot find any other permanent solution. On Mar 3, 10:38 pm, Adrian Vintu adrianvi...@gmail.com wrote: Hope this will helphttp:// adrianvintu.com/blogengine/post/Force-Locale-on-Android.aspx BR, Adrian Vintu http://adrianvintu.com On Sat, Feb 27, 2010 at 3:09 PM, Menion menion.as...@gmail.com wrote: Hi mot12, sorry not post earlier. I don't know, if you find my info still useful ..., but ad 1) Yes, it's my own function that check if user selected Czech or English, so this return cz or en String. ad 2) I didn't tried this. When user change locale in PreferenceScreen, I force him to restart application. Changing of application language is not a common activity, so restart is not a bad solution I think :). But with your problem, it's relevant to my another problem. Did you try set another locale (language) and then rotate display? With my current solution, ActivityManager send this event INFO/ActivityManager(1160): Config changed: { scale=1.0 imsi=230/3 loc=en_GB touch=3 keys=2/1/1 nav=2/1 orien=2 layout=34} and language of whole application set from my (e.g. cz, to default (in this case to loc=en_GB). I think that this is similar to your problem. Grr ... Hope we find any solution ... On Feb 14, 11:45 am, mot12 martin.hu...@gmail.com wrote: Menion, Ok, now I feel silly because I thought I could figure it out from your post. 1) Settings.getLanguage() is from your own preference settings? It is no android.provider.Settings, right? 2) When my app loads, I read the language preference from my own app preference settings and set the locale using the code you gave. Works great. But if I change the language preference in my settings using updateConfiguration, I hoped I would trigger the onConfigurationChanged of my main Activity. But that doesn't happen despite my entries android:configChanges=locale for the main activity and uses-permission android:name=android.permission.CHANGE_CONFIGURATION/ in the manifest. Let's say I am in the main activity. I load the locale specified in the settings in OnCreate. Everything is great. Now I go from there to a preference activity, change the desired locale, update the configuration via updateConfiguration and using the 'back' key I go back to my main activity. Instead of onConfigurationChanged I get onResume, giving me no possibility to reload my resources. Any idea? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@googlegroups.com android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@googlegroups.com android-developers%252bunsubscr...@googlegroups.comandroid-developers%25252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
Re: [android-developers] Re: selecting language from within the app rather than by locale of the system settings
Hope this will help http://adrianvintu.com/blogengine/post/Force-Locale-on-Android.aspx BR, Adrian Vintu http://adrianvintu.com On Sat, Feb 27, 2010 at 3:09 PM, Menion menion.as...@gmail.com wrote: Hi mot12, sorry not post earlier. I don't know, if you find my info still useful ..., but ad 1) Yes, it's my own function that check if user selected Czech or English, so this return cz or en String. ad 2) I didn't tried this. When user change locale in PreferenceScreen, I force him to restart application. Changing of application language is not a common activity, so restart is not a bad solution I think :). But with your problem, it's relevant to my another problem. Did you try set another locale (language) and then rotate display? With my current solution, ActivityManager send this event INFO/ActivityManager(1160): Config changed: { scale=1.0 imsi=230/3 loc=en_GB touch=3 keys=2/1/1 nav=2/1 orien=2 layout=34} and language of whole application set from my (e.g. cz, to default (in this case to loc=en_GB). I think that this is similar to your problem. Grr ... Hope we find any solution ... On Feb 14, 11:45 am, mot12 martin.hu...@gmail.com wrote: Menion, Ok, now I feel silly because I thought I could figure it out from your post. 1) Settings.getLanguage() is from your own preference settings? It is no android.provider.Settings, right? 2) When my app loads, I read the language preference from my own app preference settings and set the locale using the code you gave. Works great. But if I change the language preference in my settings using updateConfiguration, I hoped I would trigger the onConfigurationChanged of my main Activity. But that doesn't happen despite my entries android:configChanges=locale for the main activity and uses-permission android:name=android.permission.CHANGE_CONFIGURATION/ in the manifest. Let's say I am in the main activity. I load the locale specified in the settings in OnCreate. Everything is great. Now I go from there to a preference activity, change the desired locale, update the configuration via updateConfiguration and using the 'back' key I go back to my main activity. Instead of onConfigurationChanged I get onResume, giving me no possibility to reload my resources. Any idea? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: selecting language from within the app rather than by locale of the system settings
Hi Adrian, thanks for you response. Your code is very similar to mine. Only base diference is that you use Activity.getBaseContext().getResources() instead of mine used Activity.getResources(). But this not help with my main problem. Probably in your code, every display rotate call same INFO/ActivityManager(1160): Config changed: { scale=1.0 imsi=230/3 loc=en_GB touch=3 keys=2/1/1 nav=2/1 orien=2 layout=34} and after that, locale change to default. but is seems that only solution is to call language change code in every onCreate() in every activity. Little bit weird but cannot find any other permanent solution. On Mar 3, 10:38 pm, Adrian Vintu adrianvi...@gmail.com wrote: Hope this will helphttp://adrianvintu.com/blogengine/post/Force-Locale-on-Android.aspx BR, Adrian Vintu http://adrianvintu.com On Sat, Feb 27, 2010 at 3:09 PM, Menion menion.as...@gmail.com wrote: Hi mot12, sorry not post earlier. I don't know, if you find my info still useful ..., but ad 1) Yes, it's my own function that check if user selected Czech or English, so this return cz or en String. ad 2) I didn't tried this. When user change locale in PreferenceScreen, I force him to restart application. Changing of application language is not a common activity, so restart is not a bad solution I think :). But with your problem, it's relevant to my another problem. Did you try set another locale (language) and then rotate display? With my current solution, ActivityManager send this event INFO/ActivityManager(1160): Config changed: { scale=1.0 imsi=230/3 loc=en_GB touch=3 keys=2/1/1 nav=2/1 orien=2 layout=34} and language of whole application set from my (e.g. cz, to default (in this case to loc=en_GB). I think that this is similar to your problem. Grr ... Hope we find any solution ... On Feb 14, 11:45 am, mot12 martin.hu...@gmail.com wrote: Menion, Ok, now I feel silly because I thought I could figure it out from your post. 1) Settings.getLanguage() is from your own preference settings? It is no android.provider.Settings, right? 2) When my app loads, I read the language preference from my own app preference settings and set the locale using the code you gave. Works great. But if I change the language preference in my settings using updateConfiguration, I hoped I would trigger the onConfigurationChanged of my main Activity. But that doesn't happen despite my entries android:configChanges=locale for the main activity and uses-permission android:name=android.permission.CHANGE_CONFIGURATION/ in the manifest. Let's say I am in the main activity. I load the locale specified in the settings in OnCreate. Everything is great. Now I go from there to a preference activity, change the desired locale, update the configuration via updateConfiguration and using the 'back' key I go back to my main activity. Instead of onConfigurationChanged I get onResume, giving me no possibility to reload my resources. Any idea? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: selecting language from within the app rather than by locale of the system settings
Hi mot12, sorry not post earlier. I don't know, if you find my info still useful ..., but ad 1) Yes, it's my own function that check if user selected Czech or English, so this return cz or en String. ad 2) I didn't tried this. When user change locale in PreferenceScreen, I force him to restart application. Changing of application language is not a common activity, so restart is not a bad solution I think :). But with your problem, it's relevant to my another problem. Did you try set another locale (language) and then rotate display? With my current solution, ActivityManager send this event INFO/ActivityManager(1160): Config changed: { scale=1.0 imsi=230/3 loc=en_GB touch=3 keys=2/1/1 nav=2/1 orien=2 layout=34} and language of whole application set from my (e.g. cz, to default (in this case to loc=en_GB). I think that this is similar to your problem. Grr ... Hope we find any solution ... On Feb 14, 11:45 am, mot12 martin.hu...@gmail.com wrote: Menion, Ok, now I feel silly because I thought I could figure it out from your post. 1) Settings.getLanguage() is from your own preference settings? It is no android.provider.Settings, right? 2) When my app loads, I read the language preference from my own app preference settings and set the locale using the code you gave. Works great. But if I change the language preference in my settings using updateConfiguration, I hoped I would trigger the onConfigurationChanged of my main Activity. But that doesn't happen despite my entries android:configChanges=locale for the main activity and uses-permission android:name=android.permission.CHANGE_CONFIGURATION/ in the manifest. Let's say I am in the main activity. I load the locale specified in the settings in OnCreate. Everything is great. Now I go from there to a preference activity, change the desired locale, update the configuration via updateConfiguration and using the 'back' key I go back to my main activity. Instead of onConfigurationChanged I get onResume, giving me no possibility to reload my resources. Any idea? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: selecting language from within the app rather than by locale of the system settings
Hi mot12, i was fighting with similar problem few days ago and succesfully solved. so my solution which may help you too ... String lang = Settings.getLanguage(); Resources res = activity.getResources(); DisplayMetrics dm = res.getDisplayMetrics(); Configuration config = res.getConfiguration(); String loca = ; if (lang.equals(activity.getString(R.string.pref_misc_locale_lang_en_value))) { loca = en; } else if (lang.equals(activity.getString(R.string.pref_misc_locale_lang_cs_value))) { loca = cs; } Locale locale = new Locale(loca); Locale.setDefault(locale); config.locale = locale; res.updateConfiguration(config, dm); I'm giving user posibility to choose language from app settings. When my app start (or restart after lang change, i check which lang is selected by Settings.getLanguage() and then set selected lang (in this case czech or english). One important think is that in ALL my Activities in manifest file, I have android:configChanges=locale. Everything works perfectly, for me ... Hope this help On Feb 13, 9:00 pm, mot12 martin.hu...@gmail.com wrote: Hi, Any help on this would be much appreciated. I would like to give the users of my app the possibility of selecting a language from within the application. All languages are supplied the standard way via the values-?? resource directory. However, I don't want Android to select which resource directory to use but let the user decide instead. Any ideas how to accomplish that? The rationale for this: - some languages are not supported by the Android framework and can not be selected as a locale via the system settings - if you buy a phone in Spain, it will typically not have a system setting for Russian language, if you purchase in Russia, you will have that setting. So a Russian person in Spain would prefer using the Russian language included with the app, but can't access it thanks for any suggestions, Martin -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: selecting language from within the app rather than by locale of the system settings
Hi Menion, Thank you so much for responding. You saved my weekend :). That's exactly what I was looking for. Martin -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: selecting language from within the app rather than by locale of the system settings
Menion, Ok, now I feel silly because I thought I could figure it out from your post. 1) Settings.getLanguage() is from your own preference settings? It is no android.provider.Settings, right? 2) When my app loads, I read the language preference from my own app preference settings and set the locale using the code you gave. Works great. But if I change the language preference in my settings using updateConfiguration, I hoped I would trigger the onConfigurationChanged of my main Activity. But that doesn't happen despite my entries android:configChanges=locale for the main activity and uses-permission android:name=android.permission.CHANGE_CONFIGURATION/ in the manifest. Let's say I am in the main activity. I load the locale specified in the settings in OnCreate. Everything is great. Now I go from there to a preference activity, change the desired locale, update the configuration via updateConfiguration and using the 'back' key I go back to my main activity. Instead of onConfigurationChanged I get onResume, giving me no possibility to reload my resources. Any idea? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en