Imei in Android

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.