Example usage for android.telephony TelephonyManager SIM_STATE_READY

List of usage examples for android.telephony TelephonyManager SIM_STATE_READY

Introduction

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

Prototype

int SIM_STATE_READY

To view the source code for android.telephony TelephonyManager SIM_STATE_READY.

Click Source Link

Document

SIM card state: Ready

Usage

From source file:Main.java

public static boolean canMakeCall(Context ctx) {
    TelephonyManager manager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    return manager.getSimState() == TelephonyManager.SIM_STATE_READY
            && (manager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM
                    || manager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA);
}

From source file:Main.java

public static boolean isCheckSimCardAvailable(Context context) {
    final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (tm.getSimState() != TelephonyManager.SIM_STATE_READY) {
        return false;
    }/*from  ww w  .ja v  a 2s. com*/
    return true;
}

From source file:Main.java

public static boolean isTelephonyEnabled(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE);
    return tm != null && tm.getSimState() == TelephonyManager.SIM_STATE_READY;
}

From source file:Main.java

private static boolean isTelephonyEnabled(Activity activity) {
    TelephonyManager telephonyManager = (TelephonyManager) activity
            .getSystemService(Activity.TELEPHONY_SERVICE);
    return telephonyManager != null && telephonyManager.getSimState() == TelephonyManager.SIM_STATE_READY;
}

From source file:Main.java

public static boolean isSimUsable(final Context context) {

    TelephonyManager telephonyManager1 = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    int simState = telephonyManager1.getSimState();
    switch (simState) {
    case TelephonyManager.SIM_STATE_READY:
        return true;
    }//from  w ww .  j  av a 2s.co  m

    return false;

}

From source file:Main.java

/**
 *
 * @param context/*from   ww  w  . j a v a2 s. c o m*/
 * @return bool, true se c'e il modulo telefonico oppure se la sim e attiva
 */
public static boolean isTelephonyEnabled(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null && tm.getSimState() == TelephonyManager.SIM_STATE_READY;
}

From source file:Main.java

/**
 * Returns a constant indicating the state of the default SIM card.
 * @param sim_state "getSimState()"// ww  w .  j  a v  a2 s.co  m
 */
public static String getSimStateStr(int sim_state) {
    switch (sim_state) {
    case TelephonyManager.SIM_STATE_UNKNOWN://0
        return "SIM_STATE_UNKNOWN";
    case TelephonyManager.SIM_STATE_ABSENT://1
        return "SIM_STATE_ABSENT";
    case TelephonyManager.SIM_STATE_PIN_REQUIRED://2
        return "SIM_STATE_PIN_REQUIRED";
    case TelephonyManager.SIM_STATE_PUK_REQUIRED://3
        return "SIM_STATE_PUK_REQUIRED";
    case TelephonyManager.SIM_STATE_NETWORK_LOCKED://4
        return "SIM_STATE_NETWORK_LOCKED";
    case TelephonyManager.SIM_STATE_READY://5
        return "SIM_STATE_READY";
    default:
        return UNKNOWN;
    }
}

From source file:Main.java

public static String getMNC(Context ctx) {
    String providersName = "";
    TelephonyManager telephonyManager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager.getSimState() == TelephonyManager.SIM_STATE_READY) {
        providersName = telephonyManager.getSimOperator();
        providersName = providersName == null ? "" : providersName;
    }/*from w w w  .  j  a  v  a  2  s  .c om*/
    return providersName;
}

From source file:Main.java

public static String getCountry(Context ctx) {
    TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    Locale locale = Locale.getDefault();
    return tm.getSimState() == TelephonyManager.SIM_STATE_READY
            ? tm.getSimCountryIso().toLowerCase(Locale.getDefault())
            : locale.getCountry().toLowerCase(locale);
}

From source file:org.xwalk.runtime.extension.api.messaging.MessagingSmsManager.java

private boolean checkService(String serviceID) {
    TelephonyManager tm = (TelephonyManager) mMainActivity.getSystemService(Context.TELEPHONY_SERVICE);
    return (TelephonyManager.SIM_STATE_READY == tm.getSimState());
}