微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > 如何获取IMEI号和MEID号

如何获取IMEI号和MEID号

时间:10-02 整理:3721RD 点击:

[DESCRIPTION]

如何获取IMEI号和MEID号

[SOLUTION]

IMEI号是GSM的概念,CDMA对应的是MEID号。

IMEI(International Mobile Equipment Identity)是国际移动设备身份码,

目前GSM/WCDMA/LTE手机终端需要使用IMEI号码。

在单卡工程中一个手机对应一个IMEI号;双卡工程中一张卡对应一个IMEI号,双卡共有两个IMEI号。

MEID (Mobile Equipment Identifier) 移动设备识别码,是CDMA手机的唯一身份识别码。

通过GSMPhone对象来调用getDeviceId()函数,获取到的就是IMEI号。

通过CDMAPhone对象来调用getDeviceId()函数,获取到的就是MEID号。

一、如何获取IMEI号

KK之前的版本:

下面是获得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();

L版本非C2K项目上:

GSMPhone.java中的getDeviceId()

L上面已经没有GeminiPhone;

使用方法如下:

Phone mPhone1=PhoneFactory.getPhone(PhoneConstants.SIM_ID_1);

Phone mPhone2=PhoneFactory.getPhone(PhoneConstants.SIM_ID_2);

if(mPhone1!=null)

{

String imei_sim1= mPhone1.getDeviceId();

}

if(mPhone2!=null)

{

String imei_sim2= mPhone2.getDeviceId();

}

L版本C2K项目上:

L版本C2K项目上,一张卡同时对应一个CDMAPhone和一个GSMPhone,

要获取对应卡的IMEI号,需要先获取到对应的GSMPhone对象,具体可以通过下面的方法来获取:

    SIM1-> CDMAPhone = PhoneFactory.getPhone(0).getNLtePhone()

    SIM1-> GSMPhone = PhoneFactory.getPhone(0).getLtePhone()

    SIM2->  CDMAPhone = PhoneFactory.getPhone(1).getNLtePhone()

    SIM2->  GSMPhone = PhoneFactory.getPhone(1).getLtePhone()

获取到GSMPhone对象后,通过该对象来调用getDeviceId()函数。

二、如何获取MEID号

L版本C2K项目上:

参考上面的说明,要获取MEID号,需要先获取对应卡的CDMAPhone对象,具体可以通过下面的方法来获取:

    SIM1-> CDMAPhone = PhoneFactory.getPhone(0).getNLtePhone()

    SIM1-> GSMPhone = PhoneFactory.getPhone(0).getLtePhone()

    SIM2->  CDMAPhone = PhoneFactory.getPhone(1).getNLtePhone()

    SIM2->  GSMPhone = PhoneFactory.getPhone(1).getLtePhone()

获取到CDMAPhone对象后,通过该对象来调用getDeviceId()函数。

如果电信卡插在卡1上,则使用上面SIM1的方法来获取卡1的CDMAPhone对象。

如果电信卡插在卡2上,则使用上面 SIM2 的方式来获取卡2的CDMAPhone对象。

如果同时插入两张电信卡,由于同一时刻只支持一张电信卡,则只有主卡可以获取到MEID号,

可以通过PhoneFactory.getDefaultPhone().getNLtePhone() 来获取主卡的CDMAPhone对象。

沙发坐的舒服

沙发坐的舒服

PhoneFactory.getPhone(0).getNLtePhone() 这个方法因该怎么使用?为什么我使用的时候会包没有getNLtePhone()  这个方法,是有权限要求的吗?

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top