How to programmatically detect in which country the android device is located currently without using GPS?

后端 未结 3 836
小蘑菇
小蘑菇 2020-12-17 02:31

When my app runs, I want to detect the current location\'s country name and do some stuff for that specific country name, I can easily do it using geocoder, gps. But I want

3条回答
  •  爱一瞬间的悲伤
    2020-12-17 02:52

    Use this link http://ip-api.com/json ,this will provide all the information as json. From this json you can get the country easily. This site works using your current IP,it automatically detects the IP and sendback details.

    Docs http://ip-api.com/docs/api:json Hope it helps.

    This is what I got.

    {
    "as": "AS55410 C48 Okhla Industrial Estate, New Delhi-110020",
    "city": "Kochi",
    "country": "India",
    "countryCode": "IN",
    "isp": "Vodafone India",
    "lat": 9.9667,
    "lon": 76.2333,
    "org": "Vodafone India",
    "query": "123.63.81.162",
    "region": "KL",
    "regionName": "Kerala",
    "status": "success",
    "timezone": "Asia/Kolkata",
    "zip": ""
    

    }

提交回复
热议问题