SoFunction
Updated on 2025-04-09

How to get the unique identification code of Android system

This article describes the method of obtaining the unique identification code of the Android system. Share it for your reference. The details are as follows:

On computers, we are used to using MAC addresses to mark a computer. On Android devices, you can use IMIE or Android ID to sign a device.

Let's take a look at how to get such information on Android.

One is the getDeviceId of TelephonyManager, and the other is the ANDROID_ID

Here is a test code:

package com.;
import ;
import ;
import ;
import ;
import ;
import ;
/**
  * @author lixinso
  * Get the unique identification of the system
  */
public class IMIE extends Activity {
   @Override
  public void onCreate(Bundle savedInstanceState) {
    (savedInstanceState);
    setContentView();
    getImieStatus();
    getAndroidId();
  }
private void getImieStatus() {
TelephonyManager tm = (TelephonyManager)(Context.TELEPHONY_SERVICE);
String deviceId = ();
("DEVICE_ID ", deviceId + " ");
}
private void getAndroidId(){
String androidId = (getContentResolver(), System.ANDROID_ID);
("ANDROID_ID", androidId + " ");
}
}

() represents a unique device ID, for example, return IMEI for GSM phones, return MEID for CDMA phones, and return NULL if the device is not available, for example, on the simulator.

(getContentResolver(), System.ANDROID_ID) represents a 64-bit number that is randomly generated when the device is first started and remains unchanged throughout the life of the device. (It may change if factory settings are re-made)

I hope this article will be helpful to everyone's Android programming design.