无论用户位置设置如何确定Android设备的当前国家/地区位置? [英] How to determine an Android device's current country location regardless of user location settings?

查看:149
本文介绍了无论用户位置设置如何确定Android设备的当前国家/地区位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要确定设备所在的国家/地区(iso3),即使用户的设备已关闭GPS并且不允许应用访问它的位置。



我还需要考虑那些没有SIM卡的平板电脑,因此无法使用telephonyManager。



由于这个原因,我不相信我可以使用位置管理器(也是因为这些原因: LocationManager requestLocationUpdates不起作用



我认为我需要的方法是向第三方ip位置api发出一个简单的HTTP请求:
eg
http://www.ipinfodb.com/ip_location_api.php

https://freegeoip.net



<这是做这件事的最好方法吗?什么是最好的开放API使用?

解决方案

您的第三方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

这篇关于无论用户位置设置如何确定Android设备的当前国家/地区位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆