1) within the telephony framework, you can directly use the interface provided by the Gsmphone or Geminiphone.
Previous versions of KK:
IMEI (International Mobile Equipment Identity) is an international mobile device identity code, in a single card project in a mobile phone corresponding to an IMEI number, a card in the dual-SIM project corresponding to an IMEI number.
Here is the interface to get the IMEI number and demo code
Api:
Gsmphone.java in Getdeviceid ()
Geminiphone.java Getdeviceid () and Getdeviceidgemini ()
Demo Code:
Import Com.android.internal.telephony.Phone;
Import Com.android.internal.telephony.gemini.GeminiPhone;
Import Com.android.internal.telephony.PhoneFactory;
Phone phone;
Phone = Phonefactory.getdefaultphone ();
String imei= (Geminiphone) Phone.getdeviceid ();
Geminiphone Mgeminiphone;
String imei_sim1 = Mgeminiphone.getdeviceidgemini (phoneconstants.gemini_sim_1);
String imei_sim2 = Mgeminiphone.getdeviceidgemini (phoneconstants.gemini_sim_2);
On the KK version:
Gsmphone.java in Getdeviceid ()
Geminiphone.java where Getdeviceidgemini () is gone, and Getdeviceid () gets the IMEI of the default phone;
So the direct use of Gsmphone.java in the Getdeviceid () method;
Demo Code:
Geminiphone Mgeminiphone;
String Imei_sim1=mgeminiphone.getphonebyid (phoneconstants.gemini_sim_1). Getdeviceid ();
String Imei_sim2=mgeminiphone.getphonebyid (phoneconstants.gemini_sim_2). Getdeviceid ();
2) If you need to obtain the IMEI number in SDK development (third-party apk), use the Getdeviceid () method in Telephonymanager, or Getdeviceid in the Telephonymanagerex (dual Card interface) (int Simid) method.
Demo code (get Defaultphone's IMEI):
Import Android.telephony.TelephonyManager;
String Imei_sim = Telephonymanager.getdeviceid ();
Demo code (Dual Card interface):
Import android.telephony.TelephonyManagerEx;
String imei_sim1 = Telephonymanagerex.getdeviceid (phoneconstants.gemini_sim_1);
String imei_sim2 = Telephonymanagerex.getdeviceid (phoneconstants.gemini_sim_2);
How to get IMEI number in Android