The International Mobile Device Identification code (imei:international Mobile Equipment identification number) is a logo that distinguishes mobile devices and is stored on mobile devices and can be used to monitor stolen or invalid mobile devices. IMEI can be used mobile terminal equipment by typing "* #06 #" Search (different manufacturers of mobile phones required to enter different content, the same manufacturer of different phones may need to enter the content of different). Its total length is 15 bits, and each digit uses only 0~9 digits (meaning see below).
The method to obtain the IMEI is as follows: 1) through Telephonymanager.getdeviceid (); 2) If it is not acquired by the first method, it can be removed by Wifimanager.getconnectinfo (). Getmacaddress (), and 3) through Java's Uuid.randomuuid ().
Private String Getimei () {
Telephonymanager Telephonymanager = (telephonymanager) getsystemservice (Context.telephony_service);
String IMEI = Telephonymanager.getdeviceid ();
Boolean Isimei = Check (IMEI);
if (! Textutils.isempty (IMEI)) {
Isimei = Check (IMEI);
if (Isimei)
return IMEI;
}
if (Textutils.isempty (IMEI) | |!isimei) {
Start get MAC Address
Wifimanager Wifiman = (wifimanager) getsystemservice (Context.wifi_service);
if (Wifiman! = null) {
Wifiinfo Wifiinf = Wifiman.getconnectioninfo ();
if (Wifiinf! = null && wifiinf.getmacaddress ()! = NULL) {//48-bit, such as Fa:34:7c:6d:e4:d7
IMEI = Wifiinf.getmacaddress (). ReplaceAll (":", "");
return IMEI;
}
}
}
if (Textutils.isempty (IMEI) | |!isimei) {
IMEI = Uuid.randomuuid (). toString (). ReplaceAll ("-", ""),//uuid Universal Unique identifier (universally unique Identifier) (128-bit, such as 3f2504e0-4f89-11d3-9a0c-0305e82c3301)
}
return IMEI;
}
In addition, get the phone model code: essentially through the Build.model
Build.model (mobile phone model, e.g. MotoA953)
Private String Getdevicemodel () {
Build BD = new Build ();
String model = Bd. MODEL;
return model;
}
Imei in Android