Re: [android-developers] Force locale for an application, bug in 2.0?

2009-11-07 Thread Mark Murphy
Kaj Bjurman wrote:
> Does anyone know how to check the API version on the phone so that I
> at least can add a quickfix? (A conditional check and only invoce
> updateConfiguration if the API version is less than 5)

android.os.Build.VERSION has the values you need. Note that the integer
version is relatively new, so you probably want to use the string instead.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android 1.6 Programming Books: http://commonsware.com/books

-- 
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] Force locale for an application, bug in 2.0?

2009-11-07 Thread Kaj Bjurman
Hi,

I got a widget that currently is working with Android 1.5 and 1.6. A
user who has Motorola Droid phone with Android 2.0 did however report
a bug.

After some digging around I found that this is causing a bug that
causes an infinite loop:

String languageToLoad  = "en";
if (configuration != null && configuration.language == 1) {
languageToLoad  = "sv";
}
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
android.content.res.Configuration config = new
android.content.res.Configuration();
config.locale = locale;
//Causes bug in Android 2.0. But why?
context.getResources().updateConfiguration(config, context.getResources
().getDisplayMetrics());

The thing that happens is that my activity gets displayed for a very
very short time, then it is hidden, and gets displayed again. It looks
like flickering, but the logging output says this:

11-07 23:11:33.849: WARN/UsageStats(61): Something wrong here, didn't
expect "mypackagename" to be resumed
11-07 23:11:34.339: WARN/UsageStats(61): Something wrong here, didn't
expect "mypackagename" to be resumed
11-07 23:11:34.829: WARN/UsageStats(61): Something wrong here, didn't
expect "mypackagename" to be resumed
11-07 23:11:35.309: WARN/UsageStats(61): Something wrong here, didn't
expect "mypackagename" to be resumed

Everything works fine if I remove the following line:
context.getResources().updateConfiguration(config, context.getResources
().getDisplayMetrics());


Does anyone know what to do in order to solve the problem? Should I
report this bug?

Does anyone know how to check the API version on the phone so that I
at least can add a quickfix? (A conditional check and only invoce
updateConfiguration if the API version is less than 5)

Thanks
Kaj



-- 
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