android 中如何擷取IMEI號,android擷取imei號
1)在Telephony Framework內部,可以直接使用GSMPhone或GeminiPhone提供的介面。
KK之前的版本:
IMEI(International Mobile Equipment Identity)是國際行動裝置身份碼,在單卡工程中一個手機對應一個IMEI號,雙卡工程中一張卡對應一個IMEI號。
下面是獲得IMEI號的介面和demo code
API:
GSMPhone.java 中getDeviceId()
GeminiPhone.java 中getDeviceId() 和 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);
KK版本上:
GSMPhone.java 中getDeviceId()
GeminiPhone.java 其中getDeviceIdGemini()已經沒有了,而getDeviceId()擷取的是default phone的IMEI;
所以直接使用GSMPhone.java中getDeviceId()方法;
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)如需要在SDK開發(第三方APK)中擷取IMEI號,請使用TelephonyManager中的getDeviceId()方法,或TelephonyManagerEx(雙卡介面)中的getDeviceId(int simId)方法。
Demo code(擷取DefaultPhone的IMEI):
import android.telephony.TelephonyManager;
String imei_sim = TelephonyManager.getDeviceId();
Demo code(雙卡介面):
import android.telephony.TelephonyManagerEx;
String imei_sim1 = TelephonyManagerEx.getDeviceId(PhoneConstants.GEMINI_SIM_1);
String imei_sim2 = TelephonyManagerEx.getDeviceId(PhoneConstants.GEMINI_SIM_2);
怎擷取android裝置的imei號
java獲得android的imei號許可權添加 TelephonyManager telephonyManager = (TelephonyManager) this .getSystemService(Context.TELEPHONY_SERVICE); String IMEI = telephonyManager.getDeviceId(); adb命令獲得:adb shell dumpsys iphonesubinfo有時候返回為空白是因為,模組電源關閉了。重設後需要開啟模組電源才能讀出來查看機器的一些系統設定參數adb shell getprop
怎擷取android裝置的imei號
java獲得android的imei號許可權添加 TelephonyManager telephonyManager = (TelephonyManager) this .getSystemService(Context.TELEPHONY_SERVICE); String IMEI = telephonyManager.getDeviceId(); adb命令獲得:adb shell dumpsys iphonesubinfo有時候返回為空白是因為,模組電源關閉了。