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


Java TelephonyManager.SIM_STATE_READY属性代码示例

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


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

示例1: getMccMnc

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,代码行数:19,代码来源:TelephonyUtil.java

示例2: startDialPhoneNumber

@Override
public void startDialPhoneNumber(String number) {
    Intent phoneIntent = new Intent(Intent.ACTION_DIAL, Uri.fromParts(
            "tel", number, null));
    if (packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
        if (((TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE))
                .getSimState() == TelephonyManager.SIM_STATE_READY) {
            if (Settings.Global.getInt(getContext().getContentResolver(),
                    Settings.Global.AIRPLANE_MODE_ON, 0) == 0) {
                startActivity(phoneIntent);
                return;
            }
        }
    }
    Snackbar.make(phoneTextView, R.string.calls_unavailable_error, Snackbar.LENGTH_SHORT).show();
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:16,代码来源:UserInfoFragment.java

示例3: onReceive

@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,代码行数:28,代码来源:CallAndSmsPresenter.java

示例4: getMNC

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,代码行数:9,代码来源:DeviceUtils.java

示例5: getGeneralInfo

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,代码行数:28,代码来源:Util.java

示例6: isTelephonyEnabled

/**
 * Checks whether Telephony is enabled.
 *
 * @return true if enabled, otherwise false
 */
private boolean isTelephonyEnabled() {
    if (mTelephonyManager != null) {
        if (mTelephonyManager.getSimState() == TelephonyManager.SIM_STATE_READY) {
            return true;
        }
    }
    return false;
}
 
开发者ID:google-developer-training,项目名称:android-fundamentals-phone-sms,代码行数:13,代码来源:MainActivity.java

示例7: getCountry

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,代码行数:5,代码来源:DeviceUtils.java

示例8: isSimCardReady

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,代码行数:4,代码来源:DeviceUtils.java

示例9: isSimCardReady

/**
 * 判断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,代码行数:9,代码来源:PhoneUtils.java

示例10: isSimCardReady

/**
 * 判断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,代码行数:9,代码来源:PhoneUtils.java

示例11: isSimCardReady

/**
 * 判断 sim 卡是否准备好
 *
 * @return {@code true}: 是<br>{@code false}: 否
 */
public static boolean isSimCardReady(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null && tm.getSimState() == TelephonyManager.SIM_STATE_READY;
}
 
开发者ID:hushengjun,项目名称:FastAndroid,代码行数:9,代码来源:PhoneManager.java


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