3

I am creating an application for dual sim mobile phones. The application should be able to detect the sim through which the user is making a call. It can be outgoing or incoming call. I have tried to get both the IMEI nos of the device using this tutorial. But it returns null for the second IMEI no.

Any how I have to detect which sim the user is using while making or receiving a call.

Please suggest any way to achieve this.

Community
  • 1
  • 1
kittu88
  • 2,451
  • 5
  • 40
  • 80
  • @Pied Piper please look into this question. – kittu88 Feb 13 '14 at 06:21
  • well, the dual sim implementation is OEM specific and the design varies from vendor to vendor. You need to use reflection to find the exact class that can return you data of sims. Trial and error is way – Neji Feb 19 '14 at 11:55
  • [Get IMEI of both sim slots in dual sim android mobile devices][1] [1]: http://stackoverflow.com/questions/14517338/android-check-whether-the-phone-is-dual-sim/17499889#17499889 – Saravanan Sep 04 '14 at 09:03

2 Answers2

3

To see state of SIM1 type in console:

adb shell dumpsys telephony.registry

To see state of SIM2 type in console:

adb shell dumpsys telephony.registry2

mCallState changed on incoming/outgoing call. It allow to let you know which SIM card used for call

When you invoke dumpsys from Java-application, you need android.permission.DUMP in manifest. But it does not work on some new devices (they fail with "Permission Denial").

fedorqui
  • 275,237
  • 103
  • 548
  • 598
eGregory
  • 121
  • 6
0

this might give you both imei of phone which has dual sim.

    public static void samsungTwoSims(Context context) {
TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

try{

    Class<?> telephonyClass = Class.forName(telephony.getClass().getName());

    Class<?>[] parameter = new Class[1];
    parameter[0] = int.class;
    Method getFirstMethod = telephonyClass.getMethod("getDefault", parameter);

    Log.d(TAG, getFirstMethod.toString());

    Object[] obParameter = new Object[1];
    obParameter[0] = 0;
    TelephonyManager first = (TelephonyManager) getFirstMethod.invoke(null, obParameter);

    Log.d(TAG, "Device Id: " + first.getDeviceId() + ", device status: " + first.getSimState() + ", operator: " + first.getNetworkOperator() + "/" + first.getNetworkOperatorName());

    obParameter[0] = 1;
    TelephonyManager second = (TelephonyManager) getFirstMethod.invoke(null, obParameter);

    Log.d(TAG, "Device Id: " + second.getDeviceId() + ", device status: " + second.getSimState()+ ", operator: " + second.getNetworkOperator() + "/" + second.getNetworkOperatorName());
} catch (Exception e) {
    e.printStackTrace();
}   

}