get Mobile UUID - Android Phone

Android examples for Phone:wifi

Description

get Mobile UUID

Demo Code


//package com.java2s;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;

import android.content.Context;

import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;

import android.telephony.TelephonyManager;

public class Main {
    public static String getMobileUUID(Context paramContext) {
        String str1 = "";
        WifiManager wifiManager = (WifiManager) paramContext
                .getSystemService("wifi");
        if (wifiManager != null) {
            WifiInfo localWifiInfo = wifiManager.getConnectionInfo();
            if ((localWifiInfo != null)
                    && (localWifiInfo.getMacAddress() != null))
                str1 = localWifiInfo.getMacAddress().replace(":", "");
        }//from   w  ww .j  av a2s  .  co  m
        String str2 = ((TelephonyManager) paramContext
                .getSystemService("phone")).getDeviceId();
        String str3 = str1 + str2;
        Object localObject = "";
        try {
            LineNumberReader localLineNumberReader = new LineNumberReader(
                    new InputStreamReader(new ProcessBuilder(new String[] {
                            "/system/bin/cat", "/proc/cpuinfo" }).start()
                            .getInputStream()));
            for (int i = 1;; i++) {
                if (i < 100) {
                    String str5 = localLineNumberReader.readLine();
                    if (str5 != null) {
                        if (str5.indexOf("Serial") <= -1)
                            continue;
                        String str6 = str5.substring(1 + str5.indexOf(":"),
                                str5.length()).trim();
                        localObject = str6;
                    }
                }
                String str4 = str3 + (String) localObject;
                if ((str4 != null) && (str4.length() > 64))
                    str4 = str4.substring(0, 64);
                return str4;
            }
        } catch (IOException localIOException) {
            while (true)
                localIOException.printStackTrace();
        }
    }
}

Related Tutorials