Returns whether the device is voice-capable (meaning, it can do MMS) - Android android.telephony

Android examples for android.telephony:TelephonyManager

Description

Returns whether the device is voice-capable (meaning, it can do MMS)

Demo Code

import java.lang.reflect.Method;

import android.content.Context;
import android.telephony.TelephonyManager;

public class Main {

  /**//from   w  w w  . j a  v a  2s. c o m
   * Returns whether the device is voice-capable (meaning, it can do MMS).
   */
  public static boolean isMmsCapable(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager == null) {
      return false;
    }

    try {
      Class<?> partypes[] = new Class[0];
      Method sIsVoiceCapable = TelephonyManager.class.getMethod("isVoiceCapable", partypes);

      Object arglist[] = new Object[0];
      Object retobj = sIsVoiceCapable.invoke(telephonyManager, arglist);
      return (Boolean) retobj;
    } catch (java.lang.reflect.InvocationTargetException ite) {
      // Failure, must be another device.
      // Assume that it is voice capable.
    } catch (IllegalAccessException iae) {
      // Failure, must be an other device.
      // Assume that it is voice capable.
    } catch (NoSuchMethodException nsme) {
    }
    return true;
  }

}

Related Tutorials