When developing mobile apps, developers are most concerned about how many users are installed and are using the mobile apps. This requires identifying the uniqueness of the mobile phone. Currently, I know two ways to obtain the IMEI number of a mobile phone (the IMEI number is the only one that recognizes the mobile phone number ). Obtain the android ID (Android ID is the unique number of the mobile phone system ).
Method 1:
The android method for obtaining the IMEI number of a mobile phone is described in detail in the document on obtaining the IMEI number and other mobile phone information in the Android system. In Android 2.0 and later versions, obtaining the IMEI number of the mobile phone does not require the corresponding permission to read the mobile phone information.
<Uses-Permission Android: Name = "android. Permission. read_phone_state"/>
However, users of versions earlier than 1.6 account for nearly 50% of users. If you want users of versions earlier than 1.6 to obtain the IMEI number, you need to add permissions.
The advantage is that the mobile phone is uniquely identified. The disadvantage is that the corresponding user permissions may be required.
String myimsi = Android. OS. systemproperties. Get (Android. telephony. telephonyproperties. property_imsi );
String myimei = Android. OS. systemproperties. Get (Android. telephony. telephonyproperties. property_imei );
Method 2:
You can obtain the android ID number. If a mobile phone device is started for the first time, the number may be changed if the system changes.
Android ID explanation: http://androidappdocs-staging.appspot.com/reference/android/provider/settings.secure.html # android_id
Method:
String T = Android. provider. settings. system. getstring (getcontentresolver (), "android_id ");
Log. I ("huilurry", "android_id =" + t );
Ms test results:
07-13 13:12:49. 835: INFO/huilurry (17455): android_id = 20014289e714f20c
The advantage is that all versions are used for trial, but the disadvantage is that they may be repeated with other machines or changed from the local machine. Via: http://wangjun.easymorse.com /? P = 665
3. To obtain IMEI, call the getdeviceid () method of the telephonymanager class of telephonypackage.
Obtain imsi/IMEI (unique identification ID of SIM and mobile phone)
Learning Content: you will learn how to read the imsi (International Mobile User ID) and IMEI (international mobile device ID) of the SIM card in your mobile phone ). the imsi corresponds to the sim, And the IMEI corresponds to the device.
Possible application scenarios: you may need a unique ID to authorize/register, or the following two lines of code for your Android-activity license will give you a unique SIM card ID imsi and a unique device id imei.
Description:
Imsi is a unique number that identifies the only user in the GSM and UMTS networks. It is stored in the SIM card of the mobile phone and will be sent to the network through the mobile phone.
IMEI is also a unique number that identifies the only mobile phone in the GSM and UMTS networks. it is usually printed under the cell phone, dial * #06 # To See It.
Code: Here is the only way you read IMSI-ID/IMEI-ID in Android.
Java:
String myimsi = Android. OS. systemproperties. Get (Android. telephony. telephonyproperties. property_imsi );
String myimei = Android. OS. systemproperties. Get (Android. telephony. telephonyproperties. property_imei );