Java Code Examples for android.telephony.TelephonyManager#getPhoneType()

The following examples show how to use android.telephony.TelephonyManager#getPhoneType() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public static String getMccMnc(final Context context) {
  final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
  final int configMcc = context.getResources().getConfiguration().mcc;
  final int configMnc = context.getResources().getConfiguration().mnc;
  if (tm.getSimState() == TelephonyManager.SIM_STATE_READY) {
    Log.i(TAG, "Choosing MCC+MNC info from TelephonyManager.getSimOperator()");
    return tm.getSimOperator();
  } else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) {
    Log.i(TAG, "Choosing MCC+MNC info from TelephonyManager.getNetworkOperator()");
    return tm.getNetworkOperator();
  } else if (configMcc != 0 && configMnc != 0) {
    Log.i(TAG, "Choosing MCC+MNC info from current context's Configuration");
    return String.format(Locale.ROOT, "%03d%d",
        configMcc,
        configMnc == Configuration.MNC_ZERO ? 0 : configMnc);
  } else {
    return null;
  }
}
 
Example 2
Source Project: batteryhub   File: Phone.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns numeric mobile country code.
 *
 * @param context Application context
 * @return 3-digit country code
 */
public static String getMcc(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager)
            context.getSystemService(Context.TELEPHONY_SERVICE);
    String networkOperator = telephonyManager.getNetworkOperator();
    if (networkOperator != null && networkOperator.length() >= 5) {
        return networkOperator.substring(0, 3);
    }
    String operatorProperty = "gsm.operator.numeric";
    if (telephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) {
        operatorProperty = "ro.cdma.home.operator.numeric"; // CDMA
    }
    networkOperator = Specifications.getStringFromSystemProperty(context, operatorProperty);
    if (networkOperator != null && networkOperator.length() >= 5) {
        return networkOperator.substring(0, 3);
    }
    return "Unknown";
}
 
Example 3
Source Project: Android-UtilCode   File: PhoneUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 获取手机状态信息
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
 *
 * @return DeviceId(IMEI) = 99000311726612<br>
 * DeviceSoftwareVersion = 00<br>
 * Line1Number =<br>
 * NetworkCountryIso = cn<br>
 * NetworkOperator = 46003<br>
 * NetworkOperatorName = 中国电信<br>
 * NetworkType = 6<br>
 * honeType = 2<br>
 * SimCountryIso = cn<br>
 * SimOperator = 46003<br>
 * SimOperatorName = 中国电信<br>
 * SimSerialNumber = 89860315045710604022<br>
 * SimState = 5<br>
 * SubscriberId(IMSI) = 460030419724900<br>
 * VoiceMailNumber = *86<br>
 */
@SuppressLint("HardwareIds")
public static String getPhoneStatus() {
    TelephonyManager tm = (TelephonyManager) Utils.getContext()
            .getSystemService(Context.TELEPHONY_SERVICE);
    String str = "";
    str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
    str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
    str += "Line1Number = " + tm.getLine1Number() + "\n";
    str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
    str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
    str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
    str += "NetworkType = " + tm.getNetworkType() + "\n";
    str += "PhoneType = " + tm.getPhoneType() + "\n";
    str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
    str += "SimOperator = " + tm.getSimOperator() + "\n";
    str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
    str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
    str += "SimState = " + tm.getSimState() + "\n";
    str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
    str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
    return str;
}
 
Example 4
Source Project: Android-Commons   File: DeviceInfo.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Retrieves the ISO 3166-1 alpha-2 country code for the current device
 *
 * @param context a context reference
 * @return the lowercase country code or `null` if not available
 */
public static String getCountryISO2(final Context context) {
	try {
		final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
		final String simCountry = tm.getSimCountryIso();

		// if the SIM country code is available
		if (simCountry != null && simCountry.length() == 2) {
			return simCountry.toLowerCase(Locale.US);
		}
		// if the device is not 3G (would be unreliable)
		else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) {
			final String networkCountry = tm.getNetworkCountryIso();

			// if the network country code is available
			if (networkCountry != null && networkCountry.length() == 2) {
				return networkCountry.toLowerCase(Locale.US);
			}
		}
	}
	catch (Exception e) { }

	return null;
}
 
Example 5
Source Project: zone-sdk   File: TelephoneUtil.java    License: MIT License 5 votes vote down vote up
/**
 * Spreadtrum Phone.
 *
 * 获取 展讯 神机的双卡 IMSI、IMSI 信息
 */
@SuppressWarnings("ALL")
public static TeleInfo getSpreadtrumTeleInfo(Context context) {
    TeleInfo teleInfo = new TeleInfo();
    try {

        TelephonyManager tm1 = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String imsi_1 = tm1.getSubscriberId();
        String imei_1 = tm1.getDeviceId();
        int phoneType_1 = tm1.getPhoneType();
        teleInfo.imsi_1 = imsi_1;
        teleInfo.imei_1 = imei_1;
        teleInfo.phoneType_1 = phoneType_1;

        Class<?> phoneFactory = Class.forName("com.android.internal.telephony.PhoneFactory");
        Method getServiceName = phoneFactory.getMethod("getServiceName", String.class, int.class);
        getServiceName.setAccessible(true);
        String spreadTmService = (String) getServiceName.invoke(phoneFactory, Context.TELEPHONY_SERVICE, 1);

        TelephonyManager tm2 = (TelephonyManager) context.getSystemService(spreadTmService);
        String imsi_2 = tm2.getSubscriberId();
        String imei_2 = tm2.getDeviceId();
        int phoneType_2 = tm2.getPhoneType();
        teleInfo.imsi_2 = imsi_2;
        teleInfo.imei_2 = imei_2;
        teleInfo.phoneType_2 = phoneType_2;

    } catch (Exception e) {
        e.printStackTrace();
    }
    LogZSDK.INSTANCE.i( "Spreadtrum: " + teleInfo);
    return teleInfo;
}
 
Example 6
@SuppressLint("MissingPermission")
@Override
public boolean test() throws Throwable {
    PackageManager packageManager = mContext.getPackageManager();
    if (!packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) return true;

    TelephonyManager telephonyManager = (TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE);
    return telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE ||
        !TextUtils.isEmpty(telephonyManager.getDeviceId()) ||
        !TextUtils.isEmpty(telephonyManager.getSubscriberId());
}
 
Example 7
@SuppressLint("MissingPermission")
@Override
public boolean test() throws Throwable {
    PackageManager packageManager = mContext.getPackageManager();
    if (!packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) return true;

    TelephonyManager telephonyManager = (TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE);
    return telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE ||
        !TextUtils.isEmpty(telephonyManager.getDeviceId()) ||
        !TextUtils.isEmpty(telephonyManager.getSubscriberId());
}
 
Example 8
Source Project: ToolsFinal   File: DeviceUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 判断当前设备是否为手机
 * @param context
 * @return
 */
public static boolean isPhone(Context context) {
    TelephonyManager telephony = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    if (telephony.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) {
        return false;
    } else {
        return true;
    }
}
 
Example 9
Source Project: android-common   File: TelephoneUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * MTK Phone.
 *
 * 获取 MTK 神机的双卡 IMSI、IMSI 信息
 */
public static TeleInfo getMtkTeleInfo2(Context context) {
    TeleInfo teleInfo = new TeleInfo();
    try {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        Class<?> phone = Class.forName("com.android.internal.telephony.Phone");
        Field fields1 = phone.getField("GEMINI_SIM_1");
        fields1.setAccessible(true);
        int simId_1 = (Integer) fields1.get(null);
        Field fields2 = phone.getField("GEMINI_SIM_2");
        fields2.setAccessible(true);
        int simId_2 = (Integer) fields2.get(null);

        Method getDefault = TelephonyManager.class.getMethod("getDefault", int.class);
        TelephonyManager tm1 = (TelephonyManager) getDefault.invoke(tm, simId_1);
        TelephonyManager tm2 = (TelephonyManager) getDefault.invoke(tm, simId_2);

        String imsi_1 = tm1.getSubscriberId();
        String imsi_2 = tm2.getSubscriberId();
        teleInfo.imsi_1 = imsi_1;
        teleInfo.imsi_2 = imsi_2;

        String imei_1 = tm1.getDeviceId();
        String imei_2 = tm2.getDeviceId();
        teleInfo.imei_1 = imei_1;
        teleInfo.imei_2 = imei_2;

        int phoneType_1 = tm1.getPhoneType();
        int phoneType_2 = tm2.getPhoneType();
        teleInfo.phoneType_1 = phoneType_1;
        teleInfo.phoneType_2 = phoneType_2;
    } catch (Exception e) {
        e.printStackTrace();
    }
    Log.i(TAG, "MTK2: " + teleInfo);
    return teleInfo;
}
 
Example 10
Source Project: DevUtils   File: PhoneUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取 展讯 神机的双卡 IMSI、IMSI 信息
 * @return 展讯 神机的双卡 IMSI、IMSI 信息
 */
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public static TeleInfo getSpreadtrumTeleInfo() {
    TeleInfo teleInfo = new TeleInfo();
    try {
        TelephonyManager tm1 = AppUtils.getTelephonyManager();
        String imsi_1 = tm1.getSubscriberId();
        String imei_1 = tm1.getDeviceId();
        int phoneType_1 = tm1.getPhoneType();
        teleInfo.imsi_1 = imsi_1;
        teleInfo.imei_1 = imei_1;
        teleInfo.phoneType_1 = phoneType_1;

        Class<?> phoneFactory = Class.forName("com.android.internal.telephony.PhoneFactory");
        Method getServiceName = phoneFactory.getMethod("getServiceName", String.class, int.class);
        getServiceName.setAccessible(true);
        String spreadTmService = (String) getServiceName.invoke(phoneFactory, Context.TELEPHONY_SERVICE, 1);

        TelephonyManager tm2 = AppUtils.getSystemService(spreadTmService);
        String imsi_2 = tm2.getSubscriberId();
        String imei_2 = tm2.getDeviceId();
        int phoneType_2 = tm2.getPhoneType();
        teleInfo.imsi_2 = imsi_2;
        teleInfo.imei_2 = imei_2;
        teleInfo.phoneType_2 = phoneType_2;
    } catch (Exception e) {
        LogPrintUtils.eTag(TAG, e, "getSpreadtrumTeleInfo");
    }
    return teleInfo;
}
 
Example 11
Source Project: android-common   File: TelephoneUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Spreadtrum Phone.
 *
 * 获取 展讯 神机的双卡 IMSI、IMSI 信息
 */
public static TeleInfo getSpreadtrumTeleInfo(Context context) {
    TeleInfo teleInfo = new TeleInfo();
    try {

        TelephonyManager tm1 = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String imsi_1 = tm1.getSubscriberId();
        String imei_1 = tm1.getDeviceId();
        int phoneType_1 = tm1.getPhoneType();
        teleInfo.imsi_1 = imsi_1;
        teleInfo.imei_1 = imei_1;
        teleInfo.phoneType_1 = phoneType_1;

        Class<?> phoneFactory = Class.forName("com.android.internal.telephony.PhoneFactory");
        Method getServiceName = phoneFactory.getMethod("getServiceName", String.class, int.class);
        getServiceName.setAccessible(true);
        String spreadTmService = (String) getServiceName.invoke(phoneFactory, Context.TELEPHONY_SERVICE, 1);

        TelephonyManager tm2 = (TelephonyManager) context.getSystemService(spreadTmService);
        String imsi_2 = tm2.getSubscriberId();
        String imei_2 = tm2.getDeviceId();
        int phoneType_2 = tm2.getPhoneType();
        teleInfo.imsi_2 = imsi_2;
        teleInfo.imei_2 = imei_2;
        teleInfo.phoneType_2 = phoneType_2;

    } catch (Exception e) {
        e.printStackTrace();
    }
    Log.i(TAG, "Spreadtrum: " + teleInfo);
    return teleInfo;
}
 
Example 12
/**
 * Get ISO 3166-1 alpha-2 country code for this device (or null if not available).
 *
 * @return country code or null
 */
@Nullable
public static String getUserCountry() {
	Context context = Application.getAppContext();
	String locale = null;

	final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
	final String simCountry = tm.getSimCountryIso();
	if (simCountry != null && simCountry.length() == 2) { // SIM country code is available
		locale = simCountry.toUpperCase(Locale.getDefault());
	}
	else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) { // device is not 3G (would be unreliable)
		String networkCountry = tm.getNetworkCountryIso();
		if (networkCountry != null && networkCountry.length() == 2) { // network country code is available
			locale = networkCountry.toLowerCase(Locale.getDefault());
		}
	}

	if (locale == null || locale.length() != 2) {
		if (VERSION.SDK_INT >= VERSION_CODES.N) {
			locale = getDefaultLocale24().getCountry();
		}
		else {
			locale = getDefaultLocale23().getCountry();
		}
	}

	return locale;
}
 
Example 13
public void fillNumber()
{
    try
    {
        TelephonyManager tm = (TelephonyManager) ApplicationLoader.applicationContext.getSystemService(Context.TELEPHONY_SERVICE);
        if (tm.getSimState() != TelephonyManager.SIM_STATE_ABSENT && tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE)
        {
            boolean allowCall = true;
            boolean allowSms = true;
            if (Build.VERSION.SDK_INT >= 23)
            {
                allowCall = getParentActivity().checkSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED;
                allowSms = getParentActivity().checkSelfPermission(Manifest.permission.RECEIVE_SMS) == PackageManager.PERMISSION_GRANTED;
                if (checkShowPermissions && !allowCall && !allowSms)
                {
                    permissionsShowItems.clear();
                    if (!allowCall)
                    {
                        permissionsShowItems.add(Manifest.permission.READ_PHONE_STATE);
                    }
                    if (!allowSms)
                    {
                        permissionsShowItems.add(Manifest.permission.RECEIVE_SMS);
                        if (Build.VERSION.SDK_INT >= 23)
                        {
                            permissionsShowItems.add(Manifest.permission.READ_SMS);
                        }
                    }
                    if (!permissionsShowItems.isEmpty())
                    {
                        SharedPreferences preferences = MessagesController.getGlobalMainSettings();
                        if (preferences.getBoolean("firstloginshow", true) || getParentActivity().shouldShowRequestPermissionRationale(Manifest.permission.READ_PHONE_STATE) || getParentActivity().shouldShowRequestPermissionRationale(Manifest.permission.RECEIVE_SMS))
                        {
                            preferences.edit().putBoolean("firstloginshow", false).commit();
                            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
                            builder.setMessage(LocaleController.getString("AllowFillNumber", R.string.AllowFillNumber));
                            permissionsShowDialog = showDialog(builder.create());
                        }
                        else
                        {
                            getParentActivity().requestPermissions(permissionsShowItems.toArray(new String[permissionsShowItems.size()]), 7);
                        }
                    }
                    return;
                }
            }
            if (!newAccount && (allowCall || allowSms))
            {
                String number = PhoneFormat.stripExceptNumbers(tm.getLine1Number());
                String textToSet = null;
                boolean ok = false;
                if (!TextUtils.isEmpty(number))
                {
                    if (number.length() > 4)
                    {
                        for (int a = 4; a >= 1; a--)
                        {
                            String sub = number.substring(0, a);
                            String country = codesMap.get(sub);
                            if (country != null)
                            {
                                ok = true;
                                textToSet = number.substring(a, number.length());
                                codeField.setText(sub);
                                break;
                            }
                        }
                        if (!ok)
                        {
                            textToSet = number.substring(1, number.length());
                            codeField.setText(number.substring(0, 1));
                        }
                    }
                    if (textToSet != null)
                    {
                        phoneField.requestFocus();
                        phoneField.setText(textToSet);
                        phoneField.setSelection(phoneField.length());
                    }
                }
            }
        }
    }
    catch (Exception e)
    {
        FileLog.e(e);
    }
}
 
Example 14
Source Project: Android-utils   File: DeviceUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static boolean isPhone() {
    TelephonyManager tm =
            (TelephonyManager) UtilsApp.getApp().getSystemService(Context.TELEPHONY_SERVICE);
    // noinspection ConstantConditions
    return tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
}
 
Example 15
@SuppressLint("HardwareIds")
public void fillNumber(String number) {
    try {
        TelephonyManager tm = (TelephonyManager) ApplicationLoader.applicationContext.getSystemService(Context.TELEPHONY_SERVICE);
        boolean allowCall = true;
        boolean allowSms = true;
        if (number != null || tm.getSimState() != TelephonyManager.SIM_STATE_ABSENT && tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE) {
            if (Build.VERSION.SDK_INT >= 23) {
                allowCall = getParentActivity().checkSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED;
            }
            if (number != null || allowCall) {
                if (number == null) {
                    number = PhoneFormat.stripExceptNumbers(tm.getLine1Number());
                }
                String textToSet = null;
                boolean ok = false;
                if (!TextUtils.isEmpty(number)) {
                    if (number.length() > 4) {
                        for (int a = 4; a >= 1; a--) {
                            String sub = number.substring(0, a);
                            String country = codesMap.get(sub);
                            if (country != null) {
                                ok = true;
                                textToSet = number.substring(a);
                                inputFields[FIELD_PHONECODE].setText(sub);
                                break;
                            }
                        }
                        if (!ok) {
                            textToSet = number.substring(1);
                            inputFields[FIELD_PHONECODE].setText(number.substring(0, 1));
                        }
                    }
                    if (textToSet != null) {
                        inputFields[FIELD_PHONE].setText(textToSet);
                        inputFields[FIELD_PHONE].setSelection(inputFields[FIELD_PHONE].length());
                    }
                }
            }
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
}
 
Example 16
private void listing20_6() {
  String srvcName = Context.TELEPHONY_SERVICE;
  TelephonyManager telephonyManager = (TelephonyManager)getSystemService(srvcName);

  // Listing 20-6: Accessing phone-type and the device’s phone number
  String phoneTypeStr = "unknown";

  int phoneType = telephonyManager.getPhoneType();

  switch (phoneType) {
    case (TelephonyManager.PHONE_TYPE_CDMA):
      phoneTypeStr = "CDMA";
      break;
    case (TelephonyManager.PHONE_TYPE_GSM) :
      phoneTypeStr = "GSM";
      break;
    case (TelephonyManager.PHONE_TYPE_SIP):
      phoneTypeStr = "SIP";
      break;
    case (TelephonyManager.PHONE_TYPE_NONE):
      phoneTypeStr = "None";
      break;
    default: break;
  }

  Log.d(TAG, phoneTypeStr);

  // -- These require READ_PHONE_STATE uses-permission --
  int permission = ActivityCompat.checkSelfPermission(this,
    android.Manifest.permission.READ_PHONE_STATE);
  if (permission == PackageManager.PERMISSION_GRANTED) {

    // Read the IMEI for GSM or MEID for CDMA
    String deviceId = telephonyManager.getDeviceId();

    // Read the software version on the phone (note -- not the SDK version)
    String softwareVersion = telephonyManager.getDeviceSoftwareVersion();

    // Get the phone's number (if available)
    String phoneNumber = telephonyManager.getLine1Number();

    // If permission hasn't been granted, request it.
  } else {
    if (ActivityCompat.shouldShowRequestPermissionRationale(
      this, android.Manifest.permission.READ_PHONE_STATE)) {
      // TODO Display additional rationale for the requested permission.
    }
    ActivityCompat.requestPermissions(this,
      new String[]{android.Manifest.permission.READ_PHONE_STATE},
      PHONE_STATE_PERMISSION_REQUEST);
  }
}
 
Example 17
Source Project: Android-utils   File: DeviceUtils.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Returns the current phone type.
 *
 * @return the current phone type
 * <ul>
 * <li>{@link TelephonyManager#PHONE_TYPE_NONE}</li>
 * <li>{@link TelephonyManager#PHONE_TYPE_GSM }</li>
 * <li>{@link TelephonyManager#PHONE_TYPE_CDMA}</li>
 * <li>{@link TelephonyManager#PHONE_TYPE_SIP }</li>
 * </ul>
 */
public static int getPhoneType() {
    TelephonyManager tm =
            (TelephonyManager) UtilsApp.getApp().getSystemService(Context.TELEPHONY_SERVICE);
    //noinspection ConstantConditions
    return tm.getPhoneType();
}
 
Example 18
Source Project: RxTools-master   File: RxDeviceTool.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 判断设备是否是手机
 *
 * @param context 上下文
 * @return {@code true}: 是<br>{@code false}: 否
 */
public static boolean isPhone(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
}
 
Example 19
Source Project: AndroidUtilCode   File: PhoneUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Return whether the device is phone.
 *
 * @return {@code true}: yes<br>{@code false}: no
 */
public static boolean isPhone() {
    TelephonyManager tm = getTelephonyManager();
    return tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
}
 
Example 20
/**
 * Checks if the device supports phone.
 *
 * @param context the context to use.
 * @return if something goes wrong.
 */
public static boolean hasPhone(Context context) {
    TelephonyManager telephonyManager1 = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return telephonyManager1.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
}