Android TelephonyManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android TelephonyManager class.

This code example shows how to use the following methods:getDeviceId
	} 
	 
	public String getUuid()
	{		 
		TelephonyManager operator = (TelephonyManager) mCtx.getSystemService(Context.TELEPHONY_SERVICE);
		String uuid = operator.getDeviceId();
		return uuid;
	} 
	 
	public void init() 
	{ 
		mAppView.loadUrl("javascript:Device.setData('Android','" + version + "','" + this.getUuid() + "')");
	} 
	 
	public String getModel()
	{ 
		String model = android.os.Build.MODEL;
		return model;
	} 
	public String getProductName()
8
CodeRank
This code example shows how to use the following methods:getNetworkCountryIso
        return carrierId;
    } 
 
    public static String getCountryCode(Context context) {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String countryCode = tm.getNetworkCountryIso();
        if (TextUtils.isEmpty(countryCode)) {
            countryCode = "Unknown";
        } 
        return countryCode;
    } 
 
    public static String getDevice() {
        return SystemProperties.get("ro.cm.device"); 
    } 
 
    public static String getModVersion() {
        return SystemProperties.get("ro.cm.version"); 
    } 
 
8
CodeRank
This code example shows how to use the following methods:getDeviceId, getLine1Number, getNetworkCountryIso, getNetworkOperatorName, getSimCountryIso
		ctx = c;
		tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
	} 
	 
	public String getPhoneNumber() {
		return tm.getLine1Number();
	} 
	 
	public String getIMEI() {
		return tm.getDeviceId();
	} 
	 
	public String getCountryCode() {
		return tm.getNetworkCountryIso();
	} 
	 
	public String getOperatorName() {
		return tm.getNetworkOperatorName();
	} 
	 

8
CodeRank
This code example shows how to use the following methods:getPhoneType
This code example shows how to use the following methods:getDeviceId, getSimSerialNumber
This code example shows how to use the following methods:getDeviceId, getPhoneType
    } 
     
     
    public String getIMEI() {
        if(m_allowToReadPhoneState &&
            (m_telMgr.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM)) {
             
            return checkValidString(m_telMgr.getDeviceId());
        } 
        return null; 
    } 
     
     
    public String getIMSI() {
        if(m_allowToReadPhoneState && 
                (m_telMgr.getSimState() == TelephonyManager.SIM_STATE_READY)) {
             
            return checkValidString(m_telMgr.getSubscriberId());
        } 
        return null; 
7
CodeRank
This code example shows how to use the following methods:getNetworkType
    } 
     
    public static boolean is2gNetwork(Context context) {
        TelephonyManager tm = (TelephonyManager) context.
			getSystemService(Context.TELEPHONY_SERVICE);
	    int type = tm.getNetworkType();
	    if (type == TelephonyManager.NETWORK_TYPE_GPRS
	    		|| type == TelephonyManager.NETWORK_TYPE_EDGE) {
	    	return true; 
	    } 
	    return false; 
    } 
     
     
	public static int getCurrentSdkVersion() { 
		return Build.VERSION.SDK_INT;
	} 
	 
	public Location getLocation(Context context) {
		LocationManager locMan = (LocationManager) context
7
CodeRank
This code example shows how to use the following methods:getCallState
	 */ 
	private static boolean isInCall(Context context)
	{ 
		if (sInCall == -1) {
			TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
			sInCall = (byte)(manager.getCallState() == TelephonyManager.CALL_STATE_IDLE ? 0 : 1);
		} 
		return sInCall == 1;
	} 
 
	/** 
	 * Set the cached value for whether the phone is in a call. 
	 * 
	 * @param value True if in a call, false otherwise. 
	 */ 
	public static void setInCall(boolean value)
	{ 
		sInCall = value ? 1 : 0;
	} 
 
7
CodeRank
This code example shows how to use the following methods:getSimState
public class SIMUtils { 
 
	public static boolean isSimCardReady(Context context) {
		TelephonyManager mTelephonyManager = (TelephonyManager) context
				.getSystemService(Service.TELEPHONY_SERVICE);
		return (mTelephonyManager.getSimState() == TelephonyManager.SIM_STATE_READY);
 
	} 
} 
7
CodeRank
This code example shows how to use the following methods:getDataState
	} 
 
	private boolean checkConnectivityState(){ 
		final TelephonyManager telephonyManager = (TelephonyManager) mContext
				.getSystemService(Context.TELEPHONY_SERVICE);
		return telephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED;
 
	} 
} 
7
CodeRank
This code example shows how to use the following methods:getDeviceId, getNetworkOperatorName, getSimCountryIso, getSimOperator, getSimSerialNumber
	public static String getIdentifiers(Context ctx) {
		StringBuilder sb = new StringBuilder();
		sb.append(getPair("serial", Build.SERIAL));
		sb.append(getPair("android_id", Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID)));
		TelephonyManager tel = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
		sb.append(getPair("device_id", tel.getDeviceId()));
		sb.append(getPair("subscriber_id", tel.getSubscriberId()));
		sb.append(getPair("sim_serial_number", tel.getSimSerialNumber()));
		sb.append(getPair("sim_country_iso", tel.getSimCountryIso()));
		sb.append(getPair("network_operator_name", tel.getNetworkOperatorName()));
		sb.append(getPair("sim_operator", tel.getSimOperator()));
		sb.append(getPair("unique_id", Crypto.md5(sb.toString())));
		return sb.toString();
	} 
 
	public static String getSystemFeatures() {
		StringBuilder sb = new StringBuilder();
		sb.append(getPair("android_release", Build.VERSION.RELEASE));
		sb.append(getPair("android_sdk_int", "" + Build.VERSION.SDK_INT));
		sb.append(getPair("device_cpu_abi", Build.CPU_ABI));
7
CodeRank
This code example shows how to use the following methods:getPhoneType
    } 
 
    public static boolean hasPhoneAbility(Context context) {
        TelephonyManager telephonyManager =
                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) {
            return false; 
        } 
 
        return true; 
    } 
 
    public static boolean isSW600DPScreen(Context context) {
        DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
        int widthPixels = displayMetrics.widthPixels;
        float density = displayMetrics.density;
        return ((widthPixels / density) >= 600);
    } 
 
    public void setTitle(int resId) {
7
CodeRank
This code example shows how to use the following methods:getDataState
This code example shows how to use the following methods:getNetworkOperator
This code example shows how to use the following methods:getDeviceId, getLine1Number, getNetworkCountryIso, getNetworkOperatorName, getSimCountryIso
		ctx = c;
		tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
	} 
	 
	public String getPhoneNumber() {
		return tm.getLine1Number();
	} 
	 
	public String getIMEI() {
		return tm.getDeviceId();
	} 
	 
	public String getCountryCode() {
		return tm.getNetworkCountryIso();
	} 
	 
	public String getOperatorName() {
		return tm.getNetworkOperatorName();
	} 
	 

7
CodeRank
This code example shows how to use the following methods:getNetworkCountryIso
  /** 
   * @return The ISO country code equivalent of the current MCC. 
   */ 
  @CalledByNative 
  public String getNetworkCountryIso() {
      return mTelManager.getNetworkCountryIso();
  } 
 
  /** 
   * Creates DeviceTelephonyInfo for a given Context. 
   * @param context A context to use. 
   * @return DeviceTelephonyInfo associated with a given Context. 
   */ 
  @CalledByNative 
  public static DeviceTelephonyInfo create(Context context) {
      return new DeviceTelephonyInfo(context);
  } 
} 
7
CodeRank
This code example shows how to use the following methods:getNetworkType
			Context context = Director.getInstance().getContext();
			TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
			if(tm == null)
				type = NetworkType.NONE;
			else { 
				int t = tm.getNetworkType();
				if(t == TelephonyManager.NETWORK_TYPE_GPRS || t == TelephonyManager.NETWORK_TYPE_UNKNOWN)
					type = NetworkType.G2;
				else if(t == TelephonyManager.NETWORK_TYPE_EDGE)
					type = NetworkType.EDGE;
				else 
					type = NetworkType.G3;
			} 
		} 
	 
		return type.ordinal();
	} 
	 
	/// check proxy existence or not 
	static boolean hasProxy() { 
7
CodeRank
This code example shows how to use the following methods:getDataState
This code example shows how to use the following methods:getPhoneType
    public String getPhoneRadioType() {
        String ret = null;
 
        TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
        if (null != telephonyManager) {
            switch(telephonyManager.getPhoneType()) {
            case 0x00000000: // TelephonyManager.PHONE_TYPE_NONE 
                ret = "none";
                break; 
            case 0x00000001: // TelephonyManager.PHONE_TYPE_GSM 
                ret = "gsm";
                break; 
            case 0x00000002: // TelephonyManager.PHONE_TYPE_CDMA 
                ret = "cdma";
                break; 
            case 0x00000003: // TelephonyManager.PHONE_TYPE_SIP 
                ret = "sip";
                break; 
            default: 
                ret = null;
7
CodeRank
This code example shows how to use the following methods:getLine1Number
This code example shows how to use the following methods:getPhoneType
		 
		return telephony;
	} 
	 
	private String getRadio(TelephonyManager manager) {
		switch(manager.getPhoneType()) {
	        case 0x00000000:  
	            return "none"; 
	        case 0x00000001: 
	            return "gsm"; 
	        case 0x00000002: 
	            return "cdma"; 
	        case 0x00000003: 
	            return "sip"; 
	        default: 
	            return null; 
	        } 
	} 
} 
7
CodeRank
This code example shows how to use the following methods:getDeviceId
This code example shows how to use the following methods:getLine1Number
	 * @param context 
	 * @return 
	 */ 
	public static String getPhoneNum(Context context){
		TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
		return tm.getLine1Number();
	} 
	 
} 
7
CodeRank
This code example shows how to use the following methods:getNetworkCountryIso
  /** 
   * @return The ISO country code equivalent of the current MCC. 
   */ 
  @CalledByNative 
  public String getNetworkCountryIso() {
      return mTelManager.getNetworkCountryIso();
  } 
 
  /** 
   * Creates DeviceTelephonyInfo for a given Context. 
   * @param context A context to use. 
   * @return DeviceTelephonyInfo associated with a given Context. 
   */ 
  @CalledByNative 
  public static DeviceTelephonyInfo create(Context context) {
      return new DeviceTelephonyInfo(context);
  } 
} 
7
CodeRank
This code example shows how to use the following methods:getDeviceId
	} 
 
	public static String IMEI(Context context) {
		TelephonyManager TelephonyMgr = (TelephonyManager) context
				.getSystemService(Context.TELEPHONY_SERVICE);
		return TelephonyMgr.getDeviceId(); // Requires READ_PHONE_STATE
	} 
 
	/** 
	 * Get the size in bytes of a bitmap. 
	 *  
	 * @param bitmap 
	 * @return size in bytes 
	 */ 
	@SuppressLint("NewApi") 
	public static int getBitmapSize(Bitmap bitmap) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
			return bitmap.getByteCount();
		} 
		// Pre HC-MR1 
7
CodeRank
This code example shows how to use the following methods:getNetworkOperatorName
		EasyJSONObject locale = new EasyJSONObject();
 
		TelephonyManager manager = (TelephonyManager) context
				.getSystemService(Context.TELEPHONY_SERVICE);
		 
		locale.put("carrier",  manager.getNetworkOperatorName());
		locale.put("country",  java.util.Locale.getDefault().getDisplayCountry());
		locale.put("language", java.util.Locale.getDefault().getDisplayLanguage());
		 
		return locale;
	} 
} 
7
CodeRank
This code example shows how to use the following methods:getNetworkOperatorName
    } 
 
    public boolean getMobileInfo() { 
        TelephonyManager tm = (TelephonyManager) ctxt.getSystemService(Context.TELEPHONY_SERVICE);
        if (tm != null) {
            carrier = tm.getNetworkOperatorName();
        } 
        return false; 
    } 
 
    public boolean getWifiInfo() { 
        WifiManager wifi = (WifiManager) ctxt.getSystemService(Context.WIFI_SERVICE);
        if (wifi != null) {
            info = wifi.getConnectionInfo();
            // Set wifi variables 
            speed = info.getLinkSpeed();
            ssid = info.getSSID();
            bssid = info.getBSSID();
            macAddress = info.getMacAddress();
            gatewayIp = getIpFromIntSigned(wifi.getDhcpInfo().gateway);
7
CodeRank
This code example shows how to use the following methods:getDeviceId
	/** 
	 * 获取设备id 
	 * */ 
	private FREObject getDevciteID()throws Exception{ 
		TelephonyManager telephoneManager = (TelephonyManager) freContext.getActivity().getSystemService(Context.TELEPHONY_SERVICE);
		String deviceID = telephoneManager.getDeviceId();
		return FREObject.newObject(deviceID);
	} 
	 
} 
7
CodeRank

Related Android TelephonyManager Questions & Answers:

See Code Examples for Android TelephonyManager Methods: