Fork me on GitHub

安卓获得imei

import android.telephony.TelephonyManager; //pengyingh 15 8 25 get uuid
import java.util.UUID; //pengyingh 15 8 25 get uuid
import android.content.Context; //pengyingh 15 8 25 get uuid


public class CommonFunc {
    public static String getUniqueID(){
        final TelephonyManager tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
        final String tmDevice, tmSerial, androidId;
        tmDevice = "" + tm.getDeviceId();
        tmSerial = "" + tm.getSimSerialNumber();
        androidId = "" + android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
        UUID deviceUuid = new UUID(androidId.hashCode(), ((long)tmDevice.hashCode() << 32) | tmSerial.hashCode());
        String uniqueId = deviceUuid.toString();
        System.out.println("获取uniqueID:"+uniqueId);
        return uniqueId;
    }
}

 

posted on 2015-08-26 18:17  pengyingh  阅读(199)  评论(0)    收藏  举报

导航