我胖 今天教我一个大招,通过访问网址 返回的JSON数据判断当前设置的处于国内外,城市等信息
直接访问此网址之后 :
http://ip.taobao.com/service/getIpInfo.php?ip=myip
会收到比如下面回复:
{"code":0,"data":{"ip":"119.123.64.**","country":"中国","area":"","region":"广东","city":"深圳","county":"XX","isp":"电信","country_id":"CN","area_id":"","region_id":"440000","city_id":"440300","county_id":"xx","isp_id":"100017"}}
那后面就可以解析JSON里面的东西拿到你想要的东西了 这个流弊,以前我都是直接判断系统语言的 = =
JSONObject data = jsonObject.getJSONObject("data");
IP = data.getString("ip") + "(" + data.getString("country")
+ data.getString("area") + "区"
+ data.getString("region") + data.getString("city")
+ data.getString("isp") + ")";
Log.e("提示", "您的IP地址是:" + IP);
nice