【问题标题】:How to get IpAddress while connect by cable如何在通过电缆连接时获取 IpAddress
【发布时间】:2017-07-11 11:21:54
【问题描述】:

这是一张桌子,我公司组装的,没有wifi没有sim,但是有线; 现在,我怎样才能获得 Ipaddress 和其他配置?

我无法使用 WifiManager/WifiInfo ...

【问题讨论】:

    标签: wifi ip-address


    【解决方案1】:

    因为是有线连接的;我们不能使用 WifiManger;我发现 Linux Shell 可以提供帮助;

    但不是我知道的。

    private String do_exec(String cmd) {
            String s = "\n";
            try {
                String[] cmdline = {"sh", "-c", cmd};
                Process p = Runtime.getRuntime().exec(cmdline);
                BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
                String line = null;
                while ((line = in.readLine()) != null) {
                    s += line + "\n";
                }
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            Log.e("do_exec", s);
            return s;
        }
    

    【讨论】:

      猜你喜欢
      • 2016-08-14
      • 1970-01-01
      • 1970-01-01
      • 2015-06-25
      • 2010-11-26
      • 2017-08-26
      • 1970-01-01
      • 1970-01-01
      • 2020-05-17
      相关资源
      最近更新 更多