zoukankan      html  css  js  c++  java
  • 获取手机IMEI 号和 IP

    没什么可说的,直接上代码:

     1 public class PhoneStateCodeUtils {
     2     /**
     3      * 获取手机imei串号
     4      */
     5     public static String getImei(Context context) {
     6         TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
     7         //设备串号
     8         String imei = tm.getDeviceId();
     9         return imei;
    10     }
    11 
    12     /**
    13      * 获取手机ip
    14      *
    15      * @return
    16      */
    17     public static String getPhoneIp() {
    18         try {
    19             for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
    20                 NetworkInterface intf = en.nextElement();
    21                 for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); ) {
    22                     InetAddress inetAddress = enumIpAddr.nextElement();
    23                     if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) {
    24                         // if (!inetAddress.isLoopbackAddress() && inetAddress
    25                         // instanceof Inet6Address) {
    26                         return inetAddress.getHostAddress().toString();
    27                     }
    28                 }
    29             }
    30         } catch (Exception e) {
    31         }
    32         return "127.0.0.1";
    33     }
    34 
    35 }
  • 相关阅读:
    qemu -net tap配置上网
    qemu所支持的网卡
    linux fdisk
    linux dd命令
    busybox inittab
    busybox相关的工具
    mongoDB全文索引
    MySql 内存表使用
    oracle数据迁移到mysql
    centOS下安装mysql workbench详细步骤
  • 原文地址:https://www.cnblogs.com/epmouse/p/5352136.html
Copyright © 2011-2022 走看看