方式一:
public String getSSID() {
WifiManager wm = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
if (wm != null) {
WifiInfo winfo = wm.getConnectionInfo();
if (winfo != null) {
String s = winfo.getSSID();
if (s.length() > 2 && s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"') {
return s.substring(1, s.length() - 1);
}
}
}
return "";
}
方式二:
private String getMacAddress(){
ConnectivityManager cm = (ConnectivityManager) MainActivity.this.getApplicationContext().getSystemService(Service.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = cm.getActiveNetworkInfo();
String extraInfo = activeNetworkInfo.getExtraInfo();
return extraInfo;
}
版权声明:本文为qq_27494201原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。