Android 获取手机信息

private void initData() {

        TelephonyManager mTm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);

        WifiManager wifiManager = (WifiManager) getActivity().getApplicationContext().getSystemService(Context.WIFI_SERVICE);

        WifiInfo wifiInfo = wifiManager.getConnectionInfo();

        String imei = mTm.getDeviceId();//得到用户Id

        String imsi = mTm.getSubscriberId();

   String deviceid = tm.getDeviceId();//获取智能设备唯一编号 

   String te1 = tm.getLine1Number();//获取本机号码 

   String imei = tm.getSimSerialNumber();//获得SIM卡的序号 

        String mtype = android.os.Build.MODEL; // 手机型号

        String numer = mTm.getLine1Number(); // 手机号码,有的可得,有的不可得

        String result = wifiInfo.getMacAddress();//MAC地址

        String mtyb= android.os.Build.BRAND;//手机品牌

        String phoneInfo = "Product: " + android.os.Build.PRODUCT;

        phoneInfo += ", CPU_ABI: " + android.os.Build.CPU_ABI;

        phoneInfo += ", TAGS: " + android.os.Build.TAGS;

        phoneInfo += ", VERSION_CODES.BASE: " + android.os.Build.VERSION_CODES.BASE;

        phoneInfo += ", SDK: " + android.os.Build.VERSION.SDK;

        phoneInfo += ", VERSION.RELEASE: " + android.os.Build.VERSION.RELEASE;

        phoneInfo += ", DEVICE: " + android.os.Build.DEVICE;

        phoneInfo += ", DISPLAY: " + android.os.Build.DISPLAY;

        phoneInfo += ", BRAND: " + android.os.Build.BRAND;

        phoneInfo += ", BOARD: " + android.os.Build.BOARD;

        phoneInfo += ", FINGERPRINT: " + android.os.Build.FINGERPRINT;

        phoneInfo += ", ID: " + android.os.Build.ID;

        phoneInfo += ", MANUFACTURER: " + android.os.Build.MANUFACTURER;

        phoneInfo += ", USER: " + android.os.Build.USER;

    }

 

    //获取手机安装的应用信息(排除系统自带)

    private String getAllApp() {

        String result = "";

        List<PackageInfo> packages = getActivity().getPackageManager().getInstalledPackages(0);

        for (PackageInfo i : packages) {

            if ((i.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {

                result += i.applicationInfo.loadLabel(getActivity().getPackageManager()).toString() + ",";

            }

        }

        return result.substring(0, result.length() - 1);

    }

    //手机CPU信息

    private String[] getCpuInfo() {

        String str1 = "/proc/cpuinfo";

        String str2 = "";

        String[] cpuInfo = {"", ""};  //1-cpu型号  //2-cpu频率

        String[] arrayOfString;

        try {

            FileReader fr = new FileReader(str1);

            BufferedReader localBufferedReader = new BufferedReader(fr, 8192);

            str2 = localBufferedReader.readLine();

            arrayOfString = str2.split("\\s+");

            for (int i = 2; i < arrayOfString.length; i++) {

                cpuInfo[0] = cpuInfo[0] + arrayOfString[i] + " ";

            }

            str2 = localBufferedReader.readLine();

            arrayOfString = str2.split("\\s+");

            cpuInfo[1] += arrayOfString[2];

            localBufferedReader.close();

        } catch (IOException e) {

        }

        return cpuInfo;

    }

 

    /**    

 * 获取手机是否root信息   

  * @return     */

    private String isRoot(){

        String bool = "Root:false";

        try{

            if ((!new File("/system/bin/su").exists()) && (!new File("/system/xbin/su").exists())){

                bool = "Root:false";

            } else {

                bool = "Root:true";

            }

        } catch (Exception e) {

        }

        return bool;

    }

 //获取本机真实的物理地址

    public String getLocalMacAddress() {

        String macAddress = Settings.Secure.getString(this.getContentResolver(), "bluetooth_address");

        return macAddress;

    }

posted @ 2017-12-25 08:34  小白look世界  阅读(4218)  评论(0编辑  收藏  举报