Example usage for android.telephony TelephonyManager PHONE_TYPE_GSM

List of usage examples for android.telephony TelephonyManager PHONE_TYPE_GSM

Introduction

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

Prototype

int PHONE_TYPE_GSM

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

Click Source Link

Document

Phone radio is GSM.

Usage

From source file:Main.java

public static String convertPhoneType(int type) {
    switch (type) {
    case TelephonyManager.PHONE_TYPE_NONE:
        return "NONE";
    case TelephonyManager.PHONE_TYPE_GSM:
        return "GSM";
    case TelephonyManager.PHONE_TYPE_CDMA:
        return "CDMA";
    case TelephonyManager.PHONE_TYPE_SIP:
        return "SIP";
    default:/*from w  w  w  . ja  v  a2s.c o m*/
        return UNKNOWN;
    }
}

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

/**
 * @param phone_type "getPhoneType()"//from   w w  w  . j a  v a 2s. c om
 * @param id_length Length of device id string.
 * @return The date Google release the given Android version.
 */
public static String getDeviceIdType(int phone_type, int id_length) {
    switch (phone_type) {
    case TelephonyManager.PHONE_TYPE_GSM://1
        return "IMEI";
    case TelephonyManager.PHONE_TYPE_CDMA://2
        if (id_length == 8) {
            return "ESN";
        }
        return "MEID";
    default:
        return UNKNOWN;
    }
}

From source file:Main.java

/**
 * Returns a constant indicating the device phone type.
 * This indicates the type of radio used to transmit voice calls.
 * @param phone_type "getPhoneType()"/* w w  w  .ja  v  a  2s  . com*/
 */
public static String getPhoneTypeStr(int phone_type) {
    switch (phone_type) {
    case TelephonyManager.PHONE_TYPE_NONE://0
        return "PHONE_TYPE_NONE";
    case TelephonyManager.PHONE_TYPE_GSM://1
        return "PHONE_TYPE_GSM";
    case TelephonyManager.PHONE_TYPE_CDMA://2
        return "PHONE_TYPE_CDMA";
    case TelephonyManager.PHONE_TYPE_SIP://3
        return "PHONE_TYPE_SIP";//API 11
    default:
        return UNKNOWN;
    }
}

From source file:Main.java

/**
 * //from   w w  w .ja v a2  s . c o  m
 * @param type
 * @return
 */
public static String getTelephonyPhoneType(int type) {
    switch (type) {
    case TelephonyManager.PHONE_TYPE_CDMA:
        return "CDMA";
    case TelephonyManager.PHONE_TYPE_GSM:
        return "GSM";
    case TelephonyManager.PHONE_TYPE_NONE:
        return "None";
    default:
        return "Unknown[" + type + "]";
    }
}

From source file:uk.ac.ucl.excites.sapelli.shared.util.android.DeviceControl.java

public static boolean isGSM(Context context) {
    return getPhoneType(context) == TelephonyManager.PHONE_TYPE_GSM;
}

From source file:pk.development.sms.detection.CellSniffer.java

@Override
public void onCellLocationChanged(CellLocation location) {

    switch (teleManager.getPhoneType()) {
    case TelephonyManager.PHONE_TYPE_GSM:
        GsmCellLocation gsmCellData = (GsmCellLocation) teleManager.getCellLocation();
        if (gsmCellData != null) {
            btsData.setLac(gsmCellData.getLac());
            btsData.setCid(gsmCellData.getCid());
            btsData.setRoaming(teleManager.isNetworkRoaming());
            btsData.setBtsType(BtsType.GSM);

            String networkProvider = teleManager.getNetworkOperator();
            if (!TextUtils.isEmpty(networkProvider)) {
                btsData.setMcc(Integer.parseInt(networkProvider.substring(0, 3)));
                btsData.setMnc(Integer.parseInt(networkProvider.substring(3)));
            }//  ww  w .  j  a  va 2 s .c  o m
        }
        break;
    case TelephonyManager.PHONE_TYPE_CDMA:
        CdmaCellLocation cdmaCellData = (CdmaCellLocation) teleManager.getCellLocation();
        if (cdmaCellData != null) {
            btsData.setLac(cdmaCellData.getNetworkId());
            btsData.setCid(cdmaCellData.getBaseStationId());
            btsData.setBtsType(BtsType.CDMA);
        }
        break;
    }
}

From source file:org.mitre.svmp.client.IntentHandler.java

private static int isTelephonyEnabled(Context context) {
    int resId = 0;
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (tm != null) {
        if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_GSM
                && !context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY))
            resId = R.string.intentHandler_toast_noTelephonyCDMA;
        else if (tm.getSimState() != TelephonyManager.SIM_STATE_READY)
            resId = R.string.intentHandler_toast_noTelephonyGSM;
    }/*from   w w  w.  j a  v  a  2s .com*/
    return resId;
}

From source file:org.mozilla.mozstumbler.service.stumblerthread.datahandling.StumblerBundle.java

public JSONObject toMLSJSON() throws JSONException {
    JSONObject item = new JSONObject();

    item.put(DataStorageContract.ReportsColumns.TIME, mGpsPosition.getTime());
    item.put(DataStorageContract.ReportsColumns.LAT, Math.floor(mGpsPosition.getLatitude() * 1.0E6) / 1.0E6);
    item.put(DataStorageContract.ReportsColumns.LON, Math.floor(mGpsPosition.getLongitude() * 1.0E6) / 1.0E6);

    if (mGpsPosition.hasAccuracy()) {
        item.put(DataStorageContract.ReportsColumns.ACCURACY, (int) Math.ceil(mGpsPosition.getAccuracy()));
    }//from   ww  w  .  ja  v  a 2  s .c  o  m

    if (mGpsPosition.hasAltitude()) {
        item.put(DataStorageContract.ReportsColumns.ALTITUDE, Math.round(mGpsPosition.getAltitude()));
    }

    if (mPhoneType == TelephonyManager.PHONE_TYPE_GSM) {
        item.put(DataStorageContract.ReportsColumns.RADIO, "gsm");
    } else if (mPhoneType == TelephonyManager.PHONE_TYPE_CDMA) {
        item.put(DataStorageContract.ReportsColumns.RADIO, "cdma");
    } else {
        // issue #598. investigate this case further in future
        item.put(DataStorageContract.ReportsColumns.RADIO, "");
    }

    JSONArray cellJSON = new JSONArray();
    for (CellInfo c : mCellData.values()) {
        JSONObject obj = c.toJSONObject();
        cellJSON.put(obj);
    }

    item.put(DataStorageContract.ReportsColumns.CELL, cellJSON);
    item.put(DataStorageContract.ReportsColumns.CELL_COUNT, cellJSON.length());

    JSONArray wifis = new JSONArray();
    for (ScanResult s : mWifiData.values()) {
        JSONObject wifiEntry = new JSONObject();
        wifiEntry.put("key", s.BSSID);
        wifiEntry.put("frequency", s.frequency);
        wifiEntry.put("signal", s.level);
        wifis.put(wifiEntry);
    }
    item.put(DataStorageContract.ReportsColumns.WIFI, wifis);
    item.put(DataStorageContract.ReportsColumns.WIFI_COUNT, wifis.length());

    return item;
}

From source file:com.fallahpoor.infocenter.fragments.SimFragment.java

private boolean isSimPresent() {

    TelephonyManager telephonyManager = (TelephonyManager) getActivity()
            .getSystemService(Context.TELEPHONY_SERVICE);

    return (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM
            && telephonyManager.getSimState() != TelephonyManager.SIM_STATE_ABSENT);

}