How to get the mobile number of current sim card in real device?

前端 未结 6 1592
春和景丽
春和景丽 2020-11-28 03:39

I have to make an application which shows the contact no of the SIM card that is being used in the cell. For that I need to use TelephonyManager class. Can I ge

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 04:36

    I have to make an application which shows the Contact no of the SIM card that is being used in the cell. For that I need to use Telephony Manager class. Can i get details on its usage?

    Yes, You have to use Telephony Manager;If at all you not found the contact no. of user; You can get Sim Serial Number of Sim Card and Imei No. of Android Device by using the same Telephony Manager Class...

    Add permission:

    
    

    Import:

    import android.telephony.TelephonyManager;
    

    Use the below code:

    TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    
             // get IMEI
             imei = tm.getDeviceId();
    
             // get SimSerialNumber
             simSerialNumber = tm.getSimSerialNumber();
    

提交回复
热议问题