问题描述
我需要确定设备所在的国家/地区(iso3),即使用户的设备已关闭GPS并且不允许应用访问它的位置。
我还需要考虑那些没有SIM卡的平板电脑,因此无法使用telephonyManager。
由于这个原因,我不相信我可以使用位置管理器(也是因为这些原因:)
我认为我需要的方法是向第三方ip位置api发出一个简单的HTTP请求:
eg
或
您的第三方ip位置API的方法似乎目前正确。可能这会帮助你
I need to determine the country (iso3) the device is in even if the user's device has GPS turned off and does not allow apps to access it's location.
I also need to account for tablets that have no sim card and thus cannot use telephonyManager.
For this reason I don't believe I can use the location manager (also because of these reasons: LocationManager requestLocationUpdates doesn't work)
The approach I am thinking I will need is to make a simple HTTP request to a third party ip location api:e.g.http://www.ipinfodb.com/ip_location_api.phporhttps://freegeoip.net
Is this the best way to do it? What is the best open api to use?
Your approach of third party ip location api seems right to currently. May be This would help you
http://ip-api.com/docs/api:json
这篇关于无论用户位置设置如何确定Android设备的当前国家/地区位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!