简体   繁体   中英

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

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)?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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