我怎样才能让我的Android设备的国家code,而不使用GPS? [英] how can i get my android device country code without using GPS?
问题描述
这是Android手机实际上并一清二楚,它在哪里? - 但那里像一个国家code或国家名称检索国家的方式
An android mobile actually does know quite well where it is - but is there a way of retrieving the country by something like a country code or country name?
没有必要知道确切的GPS位置 - 全国code或名称就足够了, 我现在用的是$ C $下这样的:
No need of knowing the exact GPS position - the country code or name is sufficient, and i am using the code for this:
String locale = context.getResources().getConfiguration().locale.getCountry(Locale.getDefault());
System.out.println("country = "+locale);
但它给了我code美
但我的设备存放在印度;
有没有办法找到设备当前的国家code,而不使用GPS或网络服务提供商。
因为我使用的平板电脑。
在此先感谢。
but it gives me code "US"
but my device kept in india;
is there any way to find device current country code without using GPS or Network Provider.
because i am using Tablet.
Thanks in Advance.
推荐答案
你不应该传递什么到 getCountry()
,删除 Locale.getDefault()
You shouldn't be passing anything in to getCountry()
, remove Locale.getDefault()
string地区= context.getResources()getConfiguration()locale.getCountry();
这篇关于我怎样才能让我的Android设备的国家code,而不使用GPS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!