The IMEI: International Mobile Equipment Identification Number (IMEI) identifies mobile devices. It is stored in mobile devices and can be used to monitor stolen or invalid mobile devices. IMEI can be found by typing "* #06 #" on mobile devices of different manufacturers. (different manufacturers may have different input content on their mobile phones ). The total length is 15 digits, and each digit only uses 0 ~ 9 ).
The method to obtain IMEI is as follows: 1) Use telephonymanager. getdeviceid (); 2) if the first method cannot be obtained, you can use wifimanager. getconnectinfo (). getmacaddress (): remove it. 3) use Java's UUID. randomuuid (), remove.
Private string getimei (){
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 bits, 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 bits, such as identifier)
}
Return IMEI;
}
In addition, you can obtain the mobile phone model code by using build. model.
// Build. Model (mobile phone model, such as motoa953)
Private string getdevicemodel (){
Build BD = new build ();
String Model = BD. model;
Return Model;
}