TelephonyManager getDeviceId - top ranked examples from Open Source projects

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

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: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: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: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:getDeviceId
	 * @param context 
	 * @return 
	 */ 
    public static String getUdid(Context context) {
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String imei = telephonyManager.getDeviceId();
 
        if (AndroidUtil.isValidImei(imei)) {
            return imei;
        } 
         
        String androidId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
        if (!StringUtils.isEmpty(androidId) && !INVALID_ANDROIDID.equals(androidId.toLowerCase())) {
            return androidId;
        } 
         
        String macAddress = AndroidUtil.getWifiMacAddress(context);
        if (!StringUtils.isEmpty(macAddress)) {
            String udid = StringUtils.toMD5(macAddress
                    + Build.MODEL + Build.MANUFACTURER
7
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();
	} 
	 

7
CodeRank
This code example shows how to use the following methods:getDeviceId
 
public class Utilities { 
    public static String getUniqueID(Context ctx){
        TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
 
        String device_id = digest(tm.getDeviceId());
 
        return device_id;
    } 
     
    public static String getCarrier(Context ctx) {
        TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
        String carrier = tm.getNetworkOperatorName();
        if ("".equals(carrier)) {
            carrier = "Unknown";
        } 
        return carrier;
    } 
 
    public static String getCarrierId(Context ctx) {
7
CodeRank
This code example shows how to use the following methods:getCallState, getCellLocation, getDeviceId, getDeviceSoftwareVersion, getNetworkOperator
		TelephonyManager telephonyManager =
		(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
		 
		 
		/** Network Information **/ 
		String nomOperateurReseau = telephonyManager.getNetworkOperatorName();
		if (nomOperateurReseau != null)
		{ 
			Log.v("Network Operator Name", nomOperateurReseau);
		} 
		 
		/** CellID Lookup **/	 
		GsmCellLocation location = (GsmCellLocation) telephonyManager.getCellLocation();
		try { 
		int cid = location.getCid();
		int lac = location.getLac();
		if (Integer.toString(cid) != null && Integer.toString(lac) != null) {
			Log.v("CellID Information", Integer.toString(cid));
			Log.v("Location Area Code Information", Integer.toString(lac));
		} 

6
CodeRank
This code example shows how to use the following methods:getDeviceId

Related TelephonyManager getDeviceId Questions & Answers:

getDeviceId Method Overview
Returns the unique device ID, for example, the IMEI for GSM and the MEID or ESN for CDMA phones.
See Code Examples for other Android TelephonyManager Methods: