Android Telephone manager to detect sim

后端 未结 3 1146
日久生厌
日久生厌 2021-01-02 21:59

I am working on an Android auto-start app that\'s basically dependent on SIM card state. When my app auto starts I need it to check where the SIM card has been changed or n

3条回答
  •  臣服心动
    2021-01-02 22:25

    Below code will help you to fetch the SIM Serial No

    TelephonyManager mTelephonyMgr =
    (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
    
    String sSimSerial = mTelephonyMgr.getSimSerialNumber(); 
    

    Set the following permission on Android Manifest file

    android.permission.READ_PHONE_STATE

提交回复
热议问题