Code example for TelephonyManager

Methods: getNetworkType, getSimState

0
    /* (non-Javadoc) 
     * @see com.wayfinder.pal.network.info.TGPPInfo#supportsCellID() 
     */ 
    public boolean supportsCellID() { 
    	return (m_cellIdAllowed && 
    		m_telMgr.getSimState() == TelephonyManager.SIM_STATE_READY &&
    		is3GPPNetwork()); 
    } 
     
    /* (non-Javadoc) 
     * @see com.wayfinder.pal.network.info.TGPPInfo#supportsLAC() 
     */ 
    public boolean supportsLAC() { 
        return supportsCellID(); 
    } 
 
    /* (non-Javadoc) 
     * @see com.wayfinder.pal.network.info.TGPPInfo#supportsCurrentMCC() 
     */ 
    public boolean supportsCurrentMCC() { 
        return m_telMgr.getSimState() == TelephonyManager.SIM_STATE_READY;
    } 
 
    /* (non-Javadoc) 
     * @see com.wayfinder.pal.network.info.TGPPInfo#supportsCurrentMNC() 
     */ 
    public boolean supportsCurrentMNC() { 
        return supportsCurrentMCC(); 
    } 
 
    /* (non-Javadoc) 
     * @see com.wayfinder.pal.network.info.TGPPInfo#supportsHomeMCC() 
     */ 
    public boolean supportsHomeMCC() { 
        return m_telMgr.getSimState() == TelephonyManager.SIM_STATE_READY;
    } 
 
    /* (non-Javadoc) 
     * @see com.wayfinder.pal.network.info.TGPPInfo#supportsHomeMNC() 
     */ 
    public boolean supportsHomeMNC() { 
        return supportsHomeMCC(); 
    } 
 
    private GsmCellLocation getGsmCellLocation() {	
    	if (m_cellIdAllowed) {
    		CellLocation cellLocation = m_telMgr.getCellLocation();
    		if (cellLocation instanceof GsmCellLocation) {
        		return (GsmCellLocation)cellLocation;
    		} 
    	} 
    	return UNKNOWN_CELL;    	 
    } 
     
    private boolean is3GPPNetwork() { 
    	int type = m_telMgr.getNetworkType();
    	return (type == TelephonyManager.NETWORK_TYPE_EDGE
            || type == TelephonyManager.NETWORK_TYPE_GPRS 
        	|| type == TelephonyManager.NETWORK_TYPE_UMTS);
    }