此问题是我开发中遇到的实际问题,现在分享出来希望对大家的工作能有所帮助。
当我们需要查询手机的唯一识别码时,通常会输入*#06#来查询,此时电信手机会出来MEID号,而移动和联通会显示相应的IMEI号,那么在源码中他们是如何定义的呢,现在是MTK6755平台中关于IMEI号的部分代码:
相应的路径为:alps/packages/apps/Dialer/src/com/android/dialer/SpecialCharSequenceMgr.java
static boolean handleDeviceIdDisplay(Context context, String input) {
TelephonyManager telephonyManager =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null && input.equals(MMI_IMEI_DISPLAY)) {
int labelResId = (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) ?
R.string.imei : R.string.meid;
List<String> deviceIds = new ArrayList<String>();
for (int slot = 0; slot < telephonyManager.getPhoneCount(); slot++) {
String deviceId = telephonyManager.getDeviceId(slot);
Log.d(TAG, "handleDeviceIdDisplay(), deviceId = " + deviceId);
if (!TextUtils.isEmpty(deviceId)) {
deviceIds.add(deviceId);
}
}
/// M: Add single IMEI plugin. @{
deviceIds = ExtensionManager.getInstance().getDialPadExtension().getSingleIMEI(
deviceIds);
/// @}
AlertDialog alert = new AlertDialog.Builder(context)
.setTitle(labelResId)
.setItems(deviceIds.toArray(new String[deviceIds.size()]), null)
.setPositiveButton(android.R.string.ok, null)
.setCancelable(false)
.show();
return true;
}
return false;
}通过telephonyManager.getDeviceId()方法获取手机的唯一识别码,然后让其显示在AlertDialog上。
android开发中关于写入IMEI号问题总结
最新推荐文章于 2025-07-23 14:10:47 发布
本文探讨了在Android应用开发中如何获取手机的IMEI号,特别是针对MTK6755平台的代码实现。通过分析`Dialer`应用中的`SpecialCharSequenceMgr.java`文件,讲解了`handleDeviceIdDisplay`方法如何利用`TelephonyManager`服务检查手机类型,并展示IMEI或MEID。同时提到了单IMEI插件的扩展机制。
900

被折叠的 条评论
为什么被折叠?



