简体   繁体   English

是否可以使用getDeviceId在Android双SIM卡设备中获取不同的IMEI

[英]Is it possible to get different IMEI in android dual SIM device using getDeviceId

I am using dual SIM mobile, while dialing *#06# , I am getting two IMEI numbers (IMEI1 = ***973 & IMEI2 = ***980) . 我正在使用双SIM卡手机,在拨打*#06# ,得到了两个IMEI号码(IMEI1 = ***973 & IMEI2 = ***980)

While trying with telePhonyManager.getDeviceId() , I am always getting ***973(IMEI1) . 当尝试使用telePhonyManager.getDeviceId() ,我总是得到***973(IMEI1)

TelephonyManager mngr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

        textView.append("IMEI Number: " + mngr.getDeviceId());

In my application, I am going to use IMEI number as unique reference for user. 在我的应用程序中,我将使用IMEI编号作为用户的唯一参考。

While searching regarding it, some site posted that getDeviceId() possible to return ***980(IMEI2) . 在搜索相关内容时,一些站点发布了getDeviceId()可能返回***980(IMEI2) My question is, in future is it possible getDeviceId() method to return ***980(IMEI2)? 我的问题是,将来是否有可能getDeviceId()方法返回***980(IMEI2)?

The short answer to your question is NO , there is no foolproof way of writing code that will retrieve both IMEI numbers of a dual-SIM phone. 简短的回答你的问题是NO,有写代码,将取回的双SIM卡手机的IMEI两个数字没有万无一失的方法。 The official AOSP supports only single SIM usage, and all devices that have dual-SIM feature have had their OS source code modified by the phone manufacturers. 官方的AOSP仅支持单SIM卡使用,并且所有具有双SIM卡功能的设备的OS源代码均已由电话制造商修改。

If a phone has two SIM cards in both slots, then the IMEI number of the first slot is retrieved by default, and if a phone has only one SIM card in either slot, then the IMEI number of the occupied slot (first or second) is retrieved by default. 如果一部手机的两个插槽中都有两个SIM卡,则默认情况下将检索第一个插槽的IMEI号码;如果一部手机中的两个插槽中只有一个SIM卡,则将占用一个插槽的IMEI编号(第一个或第二个)默认情况下被检索。 This is the behavior I have observed on Micromax and HTC phones, but I suspect that this too is implementation dependent. 这是我在MicromaxHTC手机上观察到的行为,但我怀疑这也取决于实现。

I would advise you to write your code so that it is not dependent on multiple SIMs'; 我建议您编写代码,使其不依赖于多个SIM卡。 preferably, IMEI number of a phone should not be used for anything as this will probably be removed in future versions of Android. 最好不要将手机的IMEI号码用于任何用途,因为在将来的Android版本中可能会删除该号码。 iOS already prevents developers from accessing IMEI number. iOS已经阻止开发人员访问IMEI号码。

There is a post on SO where the author has used a very innovative technique - namely, reflection - to get the names of the methods for getting the second IMEI number on dual-SIM phones. 在SO上有一篇文章,作者使用了一种非常创新的技术(即反射)来获得在双SIM卡手机上获取第二个IMEI号码的方法的名称 Very interesting, but almost impossible to use in production code. 非常有趣,但是几乎不可能在生产代码中使用。

With API Level 23, Android enabled getDeviceId(slotIndex) to get different IMEI/MEID for dual sim phones. 使用API​​级别23,Android启用了getDeviceId(slotIndex)来为双卡手机获取不同的IMEI / MEID。 To get number of slots, call getPhoneCount() . 要获取插槽数,请调用getPhoneCount()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM