I am developing wearable applications (for smartwatches), and want to access the device's current country to show distance unit(km/mile) based on locale..
I am able to get the device country from Locale.getDefault().country
but once I update the local with a specific language and then later try to access the device country then it returns a blank value.
I can not use TelephonyManager
since watches/tabs don't have sim cards.
Below is the small code snippett,
val locale = Locale(language, Locale.getDefault().country)
Locale.setDefault(locale)
val configuration: Configuration = context.resources.configuration configuration.setLocale(locale) configuration.setLayoutDirection(locale)
Logger.info("Locale Country :${locale.country}")
Logger.info("Confi. Locale Country:${context.resources.configuration.locales[0].country}")
I get blank in logs.
I can save the device country before updating the local and user whenever required but if a user installs the app in India and flies to Australia still then it will still return country as India. Please guide. Thanks in advance.