Code example for TelephonyManager

Methods: getCallState, getCellLocation, getDeviceId, getDeviceSoftwareVersion, getLine1Number, getNetworkCountryIso, getNetworkOperator, getNetworkOperatorName, getPhoneType, getSimCountryIso

0
        return Build.MODEL;
    } 
 
    public static String getTelephonyOverview() {
 
        int callState = telephonyManager.getCallState();
        String callStateString = "NA";
        switch (callState) {
        case TelephonyManager.CALL_STATE_IDLE:
            callStateString = "IDLE";
            break; 
        case TelephonyManager.CALL_STATE_OFFHOOK:
            callStateString = "OFFHOOK";
            break; 
        case TelephonyManager.CALL_STATE_RINGING:
            callStateString = "RINGING";
            break; 
        } 
 
        GsmCellLocation cellLocation = (GsmCellLocation) telephonyManager.getCellLocation();
 
        String cellLocationString = "";
 
        if (cellLocation != null) {
            cellLocationString = cellLocation.getLac() + " " + cellLocation.getCid();
        } 
 
        String deviceId = telephonyManager.getDeviceId();
        String deviceSoftwareVersion = telephonyManager.getDeviceSoftwareVersion();
 
        String line1Number = telephonyManager.getLine1Number();
 
        String networkCountryIso = telephonyManager.getNetworkCountryIso();
        String networkOperator = telephonyManager.getNetworkOperator();
        String networkOperatorName = telephonyManager.getNetworkOperatorName();
 
        int phoneType = telephonyManager.getPhoneType();
        String phoneTypeString = "NA";
        switch (phoneType) {
        case TelephonyManager.PHONE_TYPE_GSM:
            phoneTypeString = "GSM";
            break; 
        case TelephonyManager.PHONE_TYPE_CDMA:
            phoneTypeString = "CDMA";
            break; 
        case TelephonyManager.PHONE_TYPE_NONE:
            phoneTypeString = "NONE";
            break; 
        } 
 
        String simCountryIso = telephonyManager.getSimCountryIso();
        String simOperator = telephonyManager.getSimOperator();
        String simOperatorName = telephonyManager.getSimOperatorName();
        String simSerialNumber = telephonyManager.getSimSerialNumber();
        String simSubscriberId = telephonyManager.getSubscriberId();
        int simState = telephonyManager.getSimState();
        String simStateString = "NA";
        switch (simState) {
        case TelephonyManager.SIM_STATE_ABSENT:
            simStateString = "ABSENT";
            break;