1. 程式人生 > >根據mac地址+deviceid獲取裝置唯一編碼 獲取手機及SIM卡相關資訊

根據mac地址+deviceid獲取裝置唯一編碼 獲取手機及SIM卡相關資訊

根據mac地址+deviceid獲取裝置唯一編碼:

private static String DEVICEKEY = "";

    /**
     * 根據mac地址+deviceid
     * 獲取裝置唯一編碼
     * @return
     */
    public static String getDeviceKey()
    {
        if ("".equals(DEVICEKEY))
        {
            String macAddress = "";
            WifiManager wifiMgr = (WifiManager)MainApplication.getIns().getSystemService(MainApplication.WIFI_SERVICE);
            WifiInfo info = (null == wifiMgr ? null : wifiMgr.getConnectionInfo());
            if (null != info)
            {
                macAddress = info.getMacAddress();
            }
            TelephonyManager telephonyManager =
                (TelephonyManager)MainApplication.getIns().getSystemService(MainApplication.TELEPHONY_SERVICE);
            String deviceId = telephonyManager.getDeviceId();
            DEVICEKEY = MD5Util.toMD5("android" + Constant.APPKEY + Constant.APPPWD + macAddress + deviceId);
        }
        return DEVICEKEY;
    }
獲取手機及SIM卡相關資訊:
/**
     * 獲取手機及SIM卡相關資訊
     * @param context
     * @return
     */
    public static Map<String, String> getPhoneInfo(Context context) {
        Map<String, String> map = new HashMap<String, String>();
        TelephonyManager tm = (TelephonyManager) context
                .getSystemService(Context.TELEPHONY_SERVICE);
        String imei = tm.getDeviceId();
        String imsi = tm.getSubscriberId();
        String phoneMode = android.os.Build.MODEL; 
        String phoneSDk = android.os.Build.VERSION.RELEASE;
        map.put("imei", imei);
        map.put("imsi", imsi);
        map.put("phoneMode", phoneMode+"##"+phoneSDk);
        map.put("model", phoneMode);
        map.put("sdk", phoneSDk);
        return map;
    }