1***@qq.com
1***@qq.com
  • 发布:2017-09-26 21:12
  • 更新:2017-09-27 19:34
  • 阅读:1249

如何获取自己手机热点的详细信息?native.js

分类:Native.js

求大神指点!在线急等

2017-09-26 21:12 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com (作者)

/**

  • 获取手机的MAC地址
  • @return
    */
    public String getMac(){
    String str="";
    String macSerial="";
    try {
    Process pp = Runtime.getRuntime().exec(
    "cat /sys/class/net/wlan0/address ");
    InputStreamReader ir = new InputStreamReader(pp.getInputStream());
    LineNumberReader input = new LineNumberReader(ir);

        for (; null != str;) {  
            str = input.readLine();  
            if (str != null) {  
                macSerial = str.trim();// 去空格  
                break;  
            }  
        }  
    } catch (Exception ex) {  
        ex.printStackTrace();  
    }  
    if (macSerial == null || "".equals(macSerial)) {  
        try {  
            return loadFileAsString("/sys/class/net/eth0/address")  
                    .toUpperCase().substring(0, 17);  
        } catch (Exception e) {  
            e.printStackTrace();  
    
        }  
    
    }  
    return macSerial;  

    }
    public static String loadFileAsString(String fileName) throws Exception {
    FileReader reader = new FileReader(fileName);
    String text = loadReaderAsString(reader);
    reader.close();
    return text;
    }
    public static String loadReaderAsString(Reader reader) throws Exception {
    StringBuilder builder = new StringBuilder();
    char[] buffer = new char[4096];
    int readLength = reader.read(buffer);
    while (readLength >= 0) {
    builder.append(buffer, 0, readLength);
    readLength = reader.read(buffer);
    }
    return builder.toString();
    }

这是安卓的方法 谁给整一下

该问题目前已经被锁定, 无法添加新回复