Example usage for android.telephony TelephonyManager isVoiceCapable

List of usage examples for android.telephony TelephonyManager isVoiceCapable

Introduction

In this page you can find the example usage for android.telephony TelephonyManager isVoiceCapable.

Prototype

public boolean isVoiceCapable() 

Source Link

Usage

From source file:ru.dublgis.androidhelpers.DesktopUtils.java

public static boolean isVoiceTelephonyAvailable(final Context ctx) {
    try {/* www.  j a  v  a2 s  .  c o  m*/
        if (!ctx.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
            return false;
        }
        final TelephonyManager manager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
        if (manager == null) {
            return false;
        }
        if (manager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) {
            return false;
        }
        if (Build.VERSION.SDK_INT >= 22) // Android 5.1+
        {
            if (!manager.isVoiceCapable()) {
                return false;
            }
        }
        return true;
    } catch (final Throwable e) {
        Log.e(TAG, "isVoiceTelephonyAvailable exception (will return 'false'): ", e);
        return false;
    }
}