android 中如何擷取IMEI號,android擷取imei號

來源:互聯網
上載者:User

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有時候返回為空白是因為,模組電源關閉了。
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.