Thursday, 28 March 2013

Android Unique Identificatin Numer

How to get android unique id number?

 
Purpose
Some times, when we are integrate our android application with server, its requirement of server that it can identify every android device uniquely. So to do that, we will learn how to get android id from device.

Android Id
A 64-bit number (as a hex string) that is randomly generated on the device's first boot and should remain constant for the lifetime of the device. (The value may change if a factory reset is performed on the device.)

Code
package com.did;

import android.app.Activity;
import android.os.Bundle;
import android.provider.Settings.Secure;
import android.util.Log;

public class DevideIdActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        String android_id = Secure.getString(this.getContentResolver(),
                Secure.ANDROID_ID);
       
        Log.d("Android","Android ID : "+android_id);
    }
}


 Output

download.jpg

No comments:

Post a Comment