当前位置: 首页>>代码示例>>Java>>正文


Java TelephonyManager.getSimState方法代码示例

本文整理汇总了Java中android.telephony.TelephonyManager.getSimState方法的典型用法代码示例。如果您正苦于以下问题:Java TelephonyManager.getSimState方法的具体用法?Java TelephonyManager.getSimState怎么用?Java TelephonyManager.getSimState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.telephony.TelephonyManager的用法示例。


在下文中一共展示了TelephonyManager.getSimState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPhoneStatus

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
 * 获取手机状态信息
 * <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>
 */
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 += "honeType = " + 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;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:42,代码来源:PhoneUtils.java

示例2: getPhoneStatus

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
 * 获取手机状态信息
 * <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.getApp()
            .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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:43,代码来源:PhoneUtils.java

示例3: getPhoneStatus

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
 * 获取手机状态信息
 * <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;
}
 
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:43,代码来源:PhoneUtils.java

示例4: getMccMnc

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
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.w(TAG, "Choosing MCC+MNC info from TelephonyManager.getSimOperator()");
    return tm.getSimOperator();
  } else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) {
    Log.w(TAG, "Choosing MCC+MNC info from TelephonyManager.getNetworkOperator()");
    return tm.getNetworkOperator();
  } else if (configMcc != 0 && configMnc != 0) {
    Log.w(TAG, "Choosing MCC+MNC info from current context's Configuration");
    return String.format("%03d%d",
        configMcc,
        configMnc == Configuration.MNC_ZERO ? 0 : configMnc);
  } else {
    return null;
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:20,代码来源:TelephonyUtil.java

示例5: getPhoneStatus

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
 * 获取手机状态信息
 * <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(Context context) {
    TelephonyManager tm = (TelephonyManager) context
            .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;
}
 
开发者ID:hushengjun,项目名称:FastAndroid,代码行数:43,代码来源:PhoneManager.java

示例6: onReceive

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    if (type != -1)
        return;
    String action = intent.getAction();
    if (Intent.ACTION_NEW_OUTGOING_CALL.equals(action)) {
        TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
        if (TelephonyManager.SIM_STATE_READY != tm.getSimState() || getAirplaneMode(mContext))  //SIM卡未准备或飞行模式拨号失败
            type = MobileCommProcessor.FailedCall;
        else
            type = MobileCommProcessor.CompletedCall;
    } else if (SMS_SEND_ACTION.equals(action)) {
        if (getResultCode() == Activity.RESULT_OK) { //短信发送成功
            type = MobileCommProcessor.CompletedSend;
            AppConfig.mContactUtils.insertSMS(phoneNumber, smsContent);
            phoneNumber = null;
            smsContent = null;
            CallAndSmsDao.getInstance(mContext).sync(CallAndSmsDao.getInstance(mContext).getSyncDao(CallAndSmsDao.MessageDao.class));
        } else {
            Log.i("LingJu", "发送短信错误码:" + getResultCode());
            type = MobileCommProcessor.FailedSend;
        }
    }
    if (type != -1) {
        EventBus.getDefault().post(new ChatMsgEvent(ChatMsgEvent.UPDATE_CALL_SMS_STATE));
        EventBus.getDefault().post(new ChatMsgEvent(new CallAndSmsMsg(keywords, type)));
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:29,代码来源:CallAndSmsPresenter.java

示例7: getMNC

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
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;
    }
    return providersName;
}
 
开发者ID:jeasinlee,项目名称:AndroidBasicLibs,代码行数:10,代码来源:DeviceUtils.java

示例8: getGeneralInfo

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static String getGeneralInfo(Context context) {
    StringBuilder sb = new StringBuilder();
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    sb.append(String.format("Interactive %B\r\n", isInteractive(context)));
    sb.append(String.format("Connected %B\r\n", isConnected(context)));
    sb.append(String.format("WiFi %B\r\n", isWifiActive(context)));
    sb.append(String.format("Metered %B\r\n", isMeteredNetwork(context)));
    sb.append(String.format("Roaming %B\r\n", isRoaming(context)));

    if (tm.getSimState() == TelephonyManager.SIM_STATE_READY)
        sb.append(String.format("SIM %s/%s/%s\r\n", tm.getSimCountryIso(), tm.getSimOperatorName(), tm.getSimOperator()));
    if (tm.getNetworkType() != TelephonyManager.NETWORK_TYPE_UNKNOWN)
        sb.append(String.format("Network %s/%s/%s\r\n", tm.getNetworkCountryIso(), tm.getNetworkOperatorName(), tm.getNetworkOperator()));

    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        sb.append(String.format("Power saving %B\r\n", pm.isPowerSaveMode()));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
        sb.append(String.format("Battery optimizing %B\r\n", batteryOptimizing(context)));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
        sb.append(String.format("Data saving %B\r\n", dataSaving(context)));

    if (sb.length() > 2)
        sb.setLength(sb.length() - 2);

    return sb.toString();
}
 
开发者ID:miankai,项目名称:MKAPP,代码行数:29,代码来源:Util.java

示例9: getSimState

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
 * 检查sim的状态
 * 
 * @return String
 */
public static String getSimState(Context context)
{
    TelephonyManager mTm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
    if (mTm != null)
    {
        switch (mTm.getSimState())
        {
            case android.telephony.TelephonyManager.SIM_STATE_UNKNOWN:
                return "未知SIM状态_" + android.telephony.TelephonyManager.SIM_STATE_UNKNOWN;
            case android.telephony.TelephonyManager.SIM_STATE_ABSENT:
                return "没插SIM卡_" + android.telephony.TelephonyManager.SIM_STATE_ABSENT;
            case android.telephony.TelephonyManager.SIM_STATE_PIN_REQUIRED:
                return "锁定SIM状态_需要用户的PIN码解锁_" + android.telephony.TelephonyManager.SIM_STATE_PIN_REQUIRED;
            case android.telephony.TelephonyManager.SIM_STATE_PUK_REQUIRED:
                return "锁定SIM状态_需要用户的PUK码解锁_" + android.telephony.TelephonyManager.SIM_STATE_PUK_REQUIRED;
            case android.telephony.TelephonyManager.SIM_STATE_NETWORK_LOCKED:
                return "锁定SIM状态_需要网络的PIN码解锁_" + android.telephony.TelephonyManager.SIM_STATE_NETWORK_LOCKED;
            case android.telephony.TelephonyManager.SIM_STATE_READY:
                return "就绪SIM状态_" + android.telephony.TelephonyManager.SIM_STATE_READY;
            default:
                return "未知SIM状态_" + android.telephony.TelephonyManager.SIM_STATE_UNKNOWN;
                
        }
    }
    return "";
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:32,代码来源:MIP_DeviceInfoUtils.java

示例10: readSIMCard

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static Object[] readSIMCard(Context context) {
    try {
        Object[] objArr = new Object[3];
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService
                ("phone");
        objArr[0] = Boolean.valueOf(false);
        switch (telephonyManager.getSimState()) {
            case 0:
                objArr[0] = Boolean.valueOf(true);
                objArr[1] = "未知状态";
                break;
            case 1:
                objArr[1] = "无卡";
                break;
            case 2:
                objArr[1] = "需要PIN解锁";
                break;
            case 3:
                objArr[1] = "需要PUK解锁";
                break;
            case 4:
                objArr[1] = "需要NetworkPIN解锁";
                break;
            case 5:
                objArr[0] = Boolean.valueOf(true);
                objArr[1] = "良好";
                break;
        }
        return objArr;
    } catch (Exception e) {
        Log.e(TAG, "cannot read SIM card. [" + e.toString() + "]");
        return null;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:35,代码来源:SocializeUtils.java

示例11: getCountry

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
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);
}
 
开发者ID:jeasinlee,项目名称:AndroidBasicLibs,代码行数:6,代码来源:DeviceUtils.java

示例12: isSimCardReady

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public static boolean isSimCardReady(Context pContext) {
    TelephonyManager tm = (TelephonyManager) pContext.getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null && tm.getSimState() == TelephonyManager.SIM_STATE_READY;
}
 
开发者ID:zeng3234,项目名称:GrowingProject,代码行数:5,代码来源:DeviceUtils.java

示例13: getPhoneStatus

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
 * 获取手机状态信息
 * <p>需添加权限<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
 * <p>返回如下
 * <pre>
 * DeviceId(IMEI) = 99000311726612
 * DeviceSoftwareVersion = 00
 * Line1Number =
 * NetworkCountryIso = cn
 * NetworkOperator = 46003
 * NetworkOperatorName = 中国电信
 * NetworkType = 6
 * honeType = 2
 * SimCountryIso = cn
 * SimOperator = 46003
 * SimOperatorName = 中国电信
 * SimSerialNumber = 89860315045710604022
 * SimState = 5
 * SubscriberId(IMSI) = 460030419724900
 * VoiceMailNumber = *86
 * <pre/>
 */
public static String getPhoneStatus(Context context) {
    TelephonyManager tm = (TelephonyManager) context
            .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 += "honeType = " + 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;
}
 
开发者ID:zhuangzaiku,项目名称:AndroidCollection,代码行数:44,代码来源:PhoneUtils.java

示例14: isSimCardReady

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
 * 判断sim卡是否准备好
 *
 * @return {@code true}: 是<br>{@code false}: 否
 */
public static boolean isSimCardReady() {
    TelephonyManager tm = (TelephonyManager) Utils.getApp().getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null && tm.getSimState() == TelephonyManager.SIM_STATE_READY;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:PhoneUtils.java

示例15: isSimCardReady

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
 * 判断sim卡是否准备好
 *
 * @return {@code true}: 是<br>{@code false}: 否
 */
public static boolean isSimCardReady() {
    TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null && tm.getSimState() == TelephonyManager.SIM_STATE_READY;
}
 
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:10,代码来源:PhoneUtils.java


注:本文中的android.telephony.TelephonyManager.getSimState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。