String GetNetIp(String ipaddr){        URL infoUrl = null;        InputStream inStream = null;        try {            infoUrl = new URL(ipaddr);            URLConnection connection = infoUrl.openConnection();            HttpURLConnection httpConnection = (HttpURLConnection)connection;            int responseCode = httpConnection.getResponseCode();            if(responseCode == HttpURLConnection.HTTP_OK)              {                     inStream = httpConnection.getInputStream();                  BufferedReader reader = new BufferedReader(new InputStreamReader(inStream,"utf-8"));               StringBuilder strber = new StringBuilder();               String line = null;               while ((line = reader.readLine()) != null)                    strber.append(line + "\n");               inStream.close();               return strber.toString();                          }        } catch (MalformedURLException e) {            // TODO Auto-generated catch block            e.printStackTrace();        } catch (IOException e) {            // TODO Auto-generated catch block            e.printStackTrace();        }       return "";    }    


查看 System.out.println((GetNetIp("http://fw.qq.com/ipaddress")));
加权限 <uses-permission android:name="android.permission.INTERNET"></uses-permission>
通过获取http://fw.qq.com/ipaddress网页取得外网IP

更多相关文章

  1. Android(安卓)TextView显示html图片
  2. Android(安卓)获取activity栈中activity
  3. Android获取设备信息(利用反射)
  4. android基于AndPermission的权限申请封装类
  5. Android(安卓)中文API:如何安全的为APK进行签名?
  6. android 显示 网络图片
  7. Android(安卓)文件打开方式
  8. 第一代Android壳源码--某某公司早期壳代码加固原理分析
  9. Android中获取屏幕长宽的方法

随机推荐

  1. 【安全】Android(安卓)O 中的 Seccomp 过
  2. Android预优化那些事
  3. 【Android(安卓)文件管理】分区存储 ( 修
  4. Unity和Android交互笔记——接入Android(
  5. Android一日游
  6. Android(安卓)控件布局常用属性
  7. Android(安卓)鲜为人知的 8 个小秘密
  8. [Android]Android部分基础学习路线图
  9. android企业级商城源码、360°全景图VR源
  10. Android编译系统(四):Android(安卓)编译