The example in this article describes the method for acquiring the unique identification code for the Android system. Share to everyone for your reference. Specifically as follows:
On the computer, we used to use the MAC address to flag a computer. On Android devices, you can use Imie or an Android ID to flag a device.
Take a look at how Android gets this information.
One is Telephonymanager's Getdeviceid, the other one is Settings.system's android_id.
Here is a piece of test code:
Package Com.npc4.android.imie;
Import android.app.Activity;
Import Android.content.Context;
Import Android.os.Bundle;
Import Android.telephony.TelephonyManager;
Import Android.util.Log;
Import Android.provider.Settings.System;
/**
* @author Lixinso
* Get the unique identification of the system/public
class Imie extends activity {
@Override
public void OnCreate (Bundle savedinstancestate) {
super.oncreate (savedinstancestate);
Setcontentview (r.layout.main);
Getimiestatus ();
Getandroidid ();
}
private void Getimiestatus () {
Telephonymanager TM = (Telephonymanager) this.getsystemservice (context.telephony_ SERVICE);
String deviceId = Tm.getdeviceid ();
LOG.E ("device_id", DeviceId + "");
}
private void Getandroidid () {
String Androidid = system.getstring (Getcontentresolver (), system.android_id);
LOG.E ("android_id", Androidid + "");
}
Tm.getdeviceid () represents a unique device ID, for example, for GSM phone return IMEI, for CDMA phone return MEID, if the device is not available to return null, such as in the simulator.
System.getstring (Getcontentresolver (), system.android_id) represents a 64-digit number that is randomly generated at the first time the device is started and is unchanged throughout the device's lifecycle. (may change if the factory settings are restarted)
I hope this article will help you with your Android program.