Local.getDefault().getCountry() 不稳定 – 图片选择器 Android 错误

huangapple go评论61阅读模式
英文:

Local.getDefault().getCountry() is not stable - Image Picker Android bug

问题

在我的应用程序中,此代码片段:

Local.getDefault().getCountry()

在应用程序启动时会立即返回正确的值,例如FR/CA/GB/US。但是过了一段时间后,它会返回一个空字符串。
(详细来说,我们在https请求中有一个语言参数,我们需要区分fr_FR、fr_CA、en_US、en_CA等等。)

如何正确获取语言的值?(如fr_FR、en_CA...)

一些与相同领域但不完全相同的主题:

Locale.getDefault().getCountry()返回空字符串 -> 此问题尚未得到回答

java.util.Locale的第一个项目为空

在真实设备中进行了测试,发现了这个异常问题:Android 6.0、8.0、9.0

英文:

In my application, this snippet:

Local.getDefault().getCountry() 

At the very soon when application launches, it returns the correct value like FR/CA/GB/US.
But after a few moment it returns an empty string.
(in detail: we have a language param for our https request, we need to different fr_FR, fr_CA, en_US, en_CA...)

How to achieve the value of language correctly? (fr_FR, en_CA,...)

Some same domain but not identical topic:

Locale.getDefault().getCountry() returning empty string -> this question is not yet answered

java.util.Locale has an empty first item

Tested and found this unusual problem in reals devices: Android 6.0, 8.0, 9.0

答案1

得分: 1

感谢laalto

我发现问题出在一个库中:Locale.setDefault()被调用了。
在我的情况下,它是ImagePicker

英文:

Thanks to laalto

I found the problem is in a library: Locale.setDefault() was called.
In my case, it was ImagePicker.

huangapple
  • 本文由 发表于 2020年8月5日 21:27:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/63266246.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定