[英]API to read user's locale settings on Android
I am trying to see if there is any API I can use to read the user's settings like date/time etc on Android device.我想看看是否有任何 API 可以用来在 Android 设备上读取用户的设置,如日期/时间等。 If the user selects 24 hour format or changes any other setting, I should be able to know about it.
如果用户选择 24 小时制或更改任何其他设置,我应该能够了解它。
Any info on this will be helpful.任何有关这方面的信息都会有所帮助。
Thanks in advance.提前致谢。
There is no all encompassing API to gather user settings.没有包罗万象的 API 来收集用户设置。 You will need to query a few different APIs to get what you need.
您将需要查询一些不同的 API 以获得所需的内容。
One is Device
一是
Device
Device.getLocale()
Device.getScreenSize()
is the common way to get the current locale setting.是获取当前区域设置的常用方法。
If you want to get an update when the user changes it you could try a broadcast receiver like in this answer:如果您想在用户更改时获得更新,您可以尝试使用广播接收器,如以下答案:
Android - Listening to a locale change without static variables Android - 在没有静态变量的情况下侦听区域设置更改
You can access the user date preferences via DateFormat.您可以通过 DateFormat 访问用户日期首选项。
DateFormat.is24HourFormat(context)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.