當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。