1、Android 获取本机Mac 地址方法:



需要在AndroidManifest.xml文件中添加权限:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

public String getLocalMacAddress() {WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);WifiInfo info = wifi.getConnectionInfo();return info.getMacAddress();}


2、Android 获取本机IP地址方法:
public String getLocalIpAddress() {try {for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {NetworkInterface intf = en.nextElement();for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {InetAddress inetAddress = enumIpAddr.nextElement();if (!inetAddress.isLoopbackAddress()) {return inetAddress.getHostAddress().toString();}}}} catch (SocketException ex) {Log.e("WifiPreference IpAddress", ex.toString());}return null;}


更多相关文章

  1. 浅谈Java中Collections.sort对List排序的两种方法
  2. Python list sort方法的具体使用
  3. python list.sort()根据多个关键字排序的方法实现
  4. 【阿里云镜像】切换阿里巴巴开源镜像站镜像——Debian镜像
  5. Android(安卓)远程链接 daemon not running 解决方法
  6. android 获取网络资源
  7. 问题:在运行android的项目时出现的异常
  8. android > Android实现计时与倒计时的几种方法
  9. 屏幕切换,保存内容

随机推荐

  1. Android基础————UI布局之高级控件详
  2. 【Android问题】解决 Android(安卓)SDK下
  3. Android版本名和API Level对应关系
  4. 移动互联网盈利知识汇总
  5. android webview 底层实现的逻辑
  6. android,进入页面textview默认获得焦点问
  7. android EditText 全面阐述
  8. How to decompile .dex file on Android
  9. android更新
  10. Android(安卓)Camera使用小结