Android Question get 2nd Sim Card Serial Number

Endien

Member
Licensed User
Longtime User
Hi all,

How to get 2nd sim card serial number ?

B4X:
Log("ph.GetSimSerialNumber " & ph.GetSimSerialNumber)

The above code is working. Its using PhoneId Library.
But it always give the 1st sim card serial number.

And then i tried SimCard lib from MarcoRome https://www.b4x.com/android/forum/threads/simcard-also-dual-sim.51301/#content


B4X:
Log("1st SIM : " & sc.GetSimSerialNumber1)
Log("2nd SIM : " & sc.GetSimSerialNumber2)

The 2nd SimCard Serial number is always null.
I tried to disable the 1st simcard manually and let just 2nd simcard active but the result is always the same.

Does somebody have managed to get 1st and 2nd simcard serial number?

PS : i am using Samsung J1
 

MarcoRome

Expert
Licensed User
Longtime User
Hi Endien.
Maybe i understood the problem ( After long search i found interesting things HERE ). The dualsim is reading in many cases, but for another cases no.
For explain better
This is part code TelephonyInfo.java:

B4X:
public static TelephonyInfo getInstance(Context context){
 
        if(telephonyInfo == null) {
 
            telephonyInfo = new TelephonyInfo();
 
            TelephonyManager telephonyManager = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE));
 
            telephonyInfo.imsiSIM1 = telephonyManager.getDeviceId();;
            telephonyInfo.imsiSIM2 = null;
 
            try {
                telephonyInfo.imsiSIM1 = getDeviceIdBySlot(context, "getDeviceIdGemini", 0);
                telephonyInfo.imsiSIM2 = getDeviceIdBySlot(context, "getDeviceIdGemini", 1);
            } catch (GeminiMethodNotFoundException e) {
                e.printStackTrace();
 
                try {
                    telephonyInfo.imsiSIM1 = getDeviceIdBySlot(context, "getDeviceId", 0);
                    telephonyInfo.imsiSIM2 = getDeviceIdBySlot(context, "getDeviceId", 1);
                } catch (GeminiMethodNotFoundException e1) {
                    //Call here for next manufacturer's predicted method name if you wish
                    e1.printStackTrace();
                }
            }
 
            telephonyInfo.isSIM1Ready = telephonyManager.getSimState() == TelephonyManager.SIM_STATE_READY;
            telephonyInfo.isSIM2Ready = false;
 
            try {
                telephonyInfo.isSIM1Ready = getSIMStateBySlot(context, "getSimStateGemini", 0);
                telephonyInfo.isSIM2Ready = getSIMStateBySlot(context, "getSimStateGemini", 1);
            } catch (GeminiMethodNotFoundException e) {
 
                e.printStackTrace();
 
                try {
                    telephonyInfo.isSIM1Ready = getSIMStateBySlot(context, "getSimState", 0);
                    telephonyInfo.isSIM2Ready = getSIMStateBySlot(context, "getSimState", 1);
                } catch (GeminiMethodNotFoundException e1) {
                    //Call here for next manufacturer's predicted method name if you wish
                    e1.printStackTrace();
                }
.......

I read that getting access of methods like "getDeviceIdGemini" for other SIM slot's detail has prediction that method exist.
If that method's name doesn't match with one given by device manufacturer than it will not work.

And so example this:

B4X:
telephonyInfo.imsiSIM1 = getDeviceIdBySlot(context,"getDeviceIdDs",0);
telephonyInfo.imsiSIM2 = getDeviceIdBySlot(context,"getDeviceIdDs",1);

Getting two IMEI numbers for both the SIM in Samsung Duos device.

B4X:
telephonyInfo.imsiSIM1 = getDeviceIdBySlot(context,"getSimSerialNumberGemini",0);
telephonyInfo.imsiSIM2 = getDeviceIdBySlot(context,"getSimSerialNumberGemini",1);

Getting two IMEI numbers for both the SIM in Lenovo Duos device.

mmhhh... if i have time this weekend i rewrite library and add also this.
 
Upvote 0

Endien

Member
Licensed User
Longtime User
Hi MarcoRome. Thanks for the reply.

Yes, i think i understand your point. Each Manufacturer had their own naming for 1st and 2nd sim card.

From this forum, maybe the promising idea is using mediatek SDK but it's limited to device that use mediatek chipset (although i had not tried it yet hehehe).
(i am having difficulties using java. It had big learning curve for me).

mmhhh... if i have time this weekend i rewrite library and add also this.

I am looking forward to your newer library. Really appreciate it, MarcoRome. And surely i will make some donation if it can help me with 2nd sim serial number.
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Hi MarcoRome. Thanks for the reply.

Yes, i think i understand your point. Each Manufacturer had their own naming for 1st and 2nd sim card.

From this forum, maybe the promising idea is using mediatek SDK but it's limited to device that use mediatek chipset (although i had not tried it yet hehehe).
(i am having difficulties using java. It had big learning curve for me).



I am looking forward to your newer library. Really appreciate it, MarcoRome. And surely i will make some donation if it can help me with 2nd sim serial number.

Hi Endien. Now is disponible Library SimCard Rel. 2. Try and send me if problem is resolved
 
Upvote 0

KY Leng

Member
Licensed User
Longtime User
For me, the Phone number = Imei. Please see the log below

asus
ASUS_Z00AD
WW_Z00A
1: - DATA_ACTIVITY_INOUT
2: - DATA_CONNECTED
3: - 352649075207124
4: - 352649075207132
5: - Moorefield
6: - http://software.intel.com/sites/landingpage/android/moorefield.xml
7: - kh
8: - 45601
9: - PHONE_TYPE_GSM
10: - kh
11: - 45601
12: -
13: - SIM_STATE_READY
14: - 456010109825003
15: - Voicemail
16: - null
17: - true
18: - 352649075207124
19: - 352649075207132
20: - false
21: - true
22: - 352649075207124
23: - 352649075207132
24: - 352649075207132
25: - cellcard


Can you tell me why (I run your code without any modification) ?
Thank you in advance.
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
For me, the Phone number = Imei. Please see the log below

asus
ASUS_Z00AD
WW_Z00A
1: - DATA_ACTIVITY_INOUT
2: - DATA_CONNECTED
3: - 352649075207124
4: - 352649075207132
5: - Moorefield
6: - http://software.intel.com/sites/landingpage/android/moorefield.xml
7: - kh
8: - 45601
9: - PHONE_TYPE_GSM
10: - kh
11: - 45601
12: -
13: - SIM_STATE_READY
14: - 456010109825003
15: - Voicemail
16: - null
17: - true
18: - 352649075207124
19: - 352649075207132
20: - false
21: - true
22: - 352649075207124
23: - 352649075207132
24: - 352649075207132
25: - cellcard


Can you tell me why (I run your code without any modification) ?
Thank you in advance.
This is standard call. I dont know why
 
Upvote 0
Top