Search code examples
androidtelephonymanager

How to get dual sim IMEI no in Android


I have to find dual sim imei number on my android phone . I have check on many website I found that I have to use getdeviceid(0) or getdeviceid(1) But its not working . It showing the error

The code is

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

            String imei = telephonyManager.getDeviceId(0);
            String imei1 = telephonyManager.getDeviceId(1);

I have attached the screenshot . Kindly check it and reply me

enter image description here


Solution

  •  TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
     String m1PhoneNumber = tMgr.getLine1Number();
     String m2PhoneNumber = tMgr.getLine2Number();
    
    
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>