How to obtain language independent values from Android Geocoder

那年仲夏 提交于 2020-02-07 06:59:13

问题


I am working on an application where i need to know the users location: country, state/province, and city/town. Then I want users to interact in some way based on their location: country, state/province, or city/town. However the geocoder gives me these locations in the language that the phone is set to. For that reason I can't accurately compare strings with other users that are in the same country, state/province, or city/town, if their language is set differently.

1 solution for countries is using the country codes. But states/provinces, or cities/towns are still a problem. Any suggestions?


回答1:


Use the constructor that accepts a Locale argument rather than the default (which uses the system locale).

See http://developer.android.com/reference/android/location/Geocoder.html

If all clients use the same locale argument, then all should receive the same response for the same requests.



来源:https://stackoverflow.com/questions/7636098/how-to-obtain-language-independent-values-from-android-geocoder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!