Android_id to guid?
<p>I am using Secure.Android_Id for getting unique id of the device. But I need to pass it to as GUID for a service. Is there a easy way to create that? </p>

<p>The basic code I wrote looks something like <strong>this</strong>: </p>

<p><code>
            String android_id = getAndroidId();
        long leastSignificantBits = 0;
        long mostSignificantBits = 0;
        UUID uuid = null;</p>

<pre><code>    if (android_id != null) {
        String asciiConvertedText = "";
        int len = android_id.length();
        for (int i = 0; i &lt; len; i++) {
            asciiConvertedText += "" + ((short) android_id.charAt(i));
        }

        len = asciiConvertedText.length();
        if (len &gt; 16) {
            leastSignificantBits = Long.parseLong(asciiConvertedText.substring(0, 15));

            if (asciiConvertedText.length() &gt; 31) {
                mostSignificantBits = Long.parseLong(asciiConvertedText.substring(16, 31));
            } else {
                mostSignificantBits = Long.parseLong(asciiConvertedText.substring(32,
                        asciiConvertedText.length()));
            }

            uuid = new UUID(mostSignificantBits, leastSignificantBits);
        } else if (len &gt; 0) {

            leastSignificantBits = Long.parseLong(asciiConvertedText);
            uuid = new UUID(mostSignificantBits, leastSignificantBits);
        } else {
            uuid = UUID.randomUUID();
        }
    }

    if (uuid != null) {
        deviceUUID = uuid.toString();
    }
</code></pre>

<p></code></p>
