0

I am using dual SIM mobile, while dialing *#06#, I am getting two IMEI numbers(IMEI1 = ***973 & IMEI2 = ***980).

While trying with telePhonyManager.getDeviceId(), I am always getting ***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.

While searching regarding it, some site posted that getDeviceId() possible to return ***980(IMEI2). My question is, in future is it possible getDeviceId() method to return ***980(IMEI2)?

SathishKumar
  • 1,644
  • 1
  • 14
  • 28
  • maybe this could help you: http://stackoverflow.com/questions/14517338/android-check-whether-the-phone-is-dual-sim/17499889#17499889 – dumbfingers Mar 04 '15 at 10:28

2 Answers2

3

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. 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.

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. This is the behavior I have observed on Micromax and HTC phones, but I suspect that this too is implementation dependent.

I would advise you to write your code so that it is not dependent on multiple SIMs'; preferably, IMEI number of a phone should not be used for anything as this will probably be removed in future versions of Android. iOS already prevents developers from accessing IMEI number.

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. Very interesting, but almost impossible to use in production code.

Community
  • 1
  • 1
Yash Sampat
  • 30,051
  • 12
  • 94
  • 120
  • thanks for your answer, i have one doubt, colleague saying that, depends on network connection enable, you will get IMEI number is it? Ex:Net enabled in SIM one means will get IMEI1, if SIM two means get IMEI2? – SathishKumar Mar 04 '15 at 10:36
  • yes precisely ... i don't think it depends on net connectivity ... if there is one sim card in either slot, then you get IMEI of that slot ... but i advise you to test my theory and your colleague's theory also ... and let me know the result! – Yash Sampat Mar 04 '15 at 11:53
  • @SathishKumar: where have you reached with this ? – Yash Sampat Mar 05 '15 at 20:07
  • I checked those scenario in Sony Xperia M Dual SIM, both not happening. Always I am getting IMEI of first SIM slot. – SathishKumar Mar 06 '15 at 11:33
  • hmm ... that means that even this is device-dependent. I have based my answer on my experience with Micromax and HTC phones – Yash Sampat Mar 06 '15 at 11:54
  • oh OK Thanks, if possible let i try with those devices. – SathishKumar Mar 06 '15 at 12:32
0

With API Level 23, Android enabled getDeviceId(slotIndex) to get different IMEI/MEID for dual sim phones. To get number of slots, call getPhoneCount().

Shawn
  • 1,598
  • 1
  • 12
  • 19