且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无论用户位置设置如何确定Android设备的当前国家/地区位置?

更新时间:2023-12-04 15:24:43

您的第三方ip位置API的方法似乎目前正确。可能这会帮助你



http: //ip-api.com/docs/api:json



http://ip-api.com/json


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.php or https://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

http://ip-api.com/json