本文整理汇总了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;
}
}
示例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();
}
示例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)));
}
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}