简体   繁体   中英

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. If the user selects 24 hour format or changes any other setting, I should be able to know about it.

Any info on this will be helpful.

Thanks in advance.

There is no all encompassing API to gather user settings. You will need to query a few different APIs to get what you need.

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

You can access the user date preferences via DateFormat.

DateFormat.is24HourFormat(context)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM