本文整理了Java中android.telephony.TelephonyManager.getSimOperator()
方法的一些代码示例,展示了TelephonyManager.getSimOperator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TelephonyManager.getSimOperator()
方法的具体详情如下:
包路径:android.telephony.TelephonyManager
类名称:TelephonyManager
方法名:getSimOperator
暂无
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
public static String getMobileOperator(Context context) {
TelephonyManager telManager = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
if(telManager==null)
return "未知运营商";
String operator = telManager.getSimOperator();
if (operator != null) {
if (operator.equals("46000") || operator.equals("46002")
|| operator.equals("46007")) {
return "中国移动";
} else if (operator.equals("46001")) {
return "中国联通";
} else if (operator.equals("46003")) {
return "中国电信";
}
}
return "未知运营商";
}
代码示例来源:origin: mbmc/FiInfo
public static String getMobileName(Context context) {
TelephonyManager telephonyManager =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager == null) {
return UNKNOWN;
}
return MobileCarrier.getName(context, telephonyManager.getSimOperator(),
telephonyManager.getSimOperatorName());
}
代码示例来源:origin: gdpancheng/LoonAndroid3
/**
* 服务商名称:例如:中国移动、联通 SIM卡的状态必须是 SIM_STATE_READY(使用getSimState()判断).
*/
public static String getSimOpertorName() {
if (mTm.getSimState() == android.telephony.TelephonyManager.SIM_STATE_READY) {
StringBuffer sb = new StringBuffer();
sb.append("SimOperatorName: ").append(mTm.getSimOperatorName());
sb.append("\n");
sb.append("SimOperator: ").append(mTm.getSimOperator());
sb.append("\n");
sb.append("Phone:").append(mTm.getLine1Number());
return sb.toString();
} else {
StringBuffer sb = new StringBuffer();
sb.append("SimOperatorName: ").append("未知");
sb.append("\n");
sb.append("SimOperator: ").append("未知");
return sb.toString();
}
}
代码示例来源:origin: square/assertj-android
public TelephonyManagerAssert hasSimOperator(String operator) {
isNotNull();
String actualOperator = actual.getSimOperator();
assertThat(actualOperator) //
.overridingErrorMessage("Expected SIM operator <%s> but was <%s>.", operator,
actualOperator) //
.isEqualTo(operator);
return this;
}
代码示例来源:origin: luhaoaimama1/zone-sdk
sb.append("\nPhoneType :").append(tm.getPhoneType());
sb.append("\nSimCountryIso :").append(tm.getSimCountryIso());
sb.append("\nSimOperator :").append(tm.getSimOperator());
sb.append("\nSimOperatorName :").append(tm.getSimOperatorName());
sb.append("\nSimSerialNumber :").append(tm.getSimSerialNumber());
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
public String getApnInfo() {
TelephonyManager tel = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
String opCode = tel.getSimOperator();
代码示例来源:origin: kibotu/net.kibotu.android.deviceinfo
simOperatorCode = telephonyManager.getSimOperator();
代码示例来源:origin: GitPhoenix/KeyboardView
/**
* 获取Sim卡运营商名称
* <p>中国移动、如中国联通、中国电信</p>
*
* @param context 上下文
* @return 移动网络运营商名称
*/
public static String getSimOperatorByMnc(Context context) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String operator = tm != null ? tm.getSimOperator() : null;
if (operator == null) return null;
switch (operator) {
case "46000":
case "46002":
case "46007":
return "中国移动";
case "46001":
return "中国联通";
case "46003":
return "中国电信";
default:
return operator;
}
}
代码示例来源:origin: antest1/kcanotify
public static String getGeneralInfo(Context context) {
StringBuilder sb = new StringBuilder();
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
sb.append(KcaUtils.format("Interactive %B\r\n", isInteractive(context)));
sb.append(KcaUtils.format("Connected %B\r\n", isConnected(context)));
sb.append(KcaUtils.format("WiFi %B\r\n", isWifiActive(context)));
sb.append(KcaUtils.format("Metered %B\r\n", isMeteredNetwork(context)));
sb.append(KcaUtils.format("Roaming %B\r\n", isRoaming(context)));
if (tm.getSimState() == TelephonyManager.SIM_STATE_READY)
sb.append(KcaUtils.format("SIM %s/%s/%s\r\n", tm.getSimCountryIso(), tm.getSimOperatorName(), tm.getSimOperator()));
if (tm.getNetworkType() != TelephonyManager.NETWORK_TYPE_UNKNOWN)
sb.append(KcaUtils.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(KcaUtils.format("Power saving %B\r\n", pm.isPowerSaveMode()));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
sb.append(KcaUtils.format("Battery optimizing %B\r\n", batteryOptimizing(context)));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
sb.append(KcaUtils.format("Data saving %B\r\n", dataSaving(context)));
if (sb.length() > 2)
sb.setLength(sb.length() - 2);
return sb.toString();
}
代码示例来源:origin: yaozs/YzsLib
/**
* 获取Sim卡运营商名称
* <p>中国移动、如中国联通、中国电信</p>
*
* @param context 上下文
* @return 移动网络运营商名称
*/
public static String getSimOperatorByMnc(Context context) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String operator = tm != null ? tm.getSimOperator() : null;
if (operator == null) return null;
switch (operator) {
case "46000":
case "46002":
case "46007":
return "中国移动";
case "46001":
return "中国联通";
case "46003":
return "中国电信";
default:
return operator;
}
}
代码示例来源:origin: stackoverflow.com
DeviceInfo deviceInfo = new DeviceInfo();
TelephonyManager tMgr = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
deviceInfo.setDeviceId(Util.getDeviceID(mContext));
if(tMgr!=null)
{
String simSerialNumber=tMgr.getSimSerialNumber();
if(simSerialNumber!=null) {
deviceInfo.setSimOperator(tMgr.getSimOperator());
deviceInfo.setSimCountryIso(tMgr.getSimCountryIso());
deviceInfo.setSimSerialNumber(simSerialNumber);
deviceInfo.setSimOperatorName(tMgr.getSimOperatorName());
deviceInfo.setSimNetworkOperator(tMgr.getNetworkOperator());
}
}
代码示例来源:origin: org.infobip.mobile.messaging.api/infobip-mobile-messaging-android-sdk
public static String getSIMNetworkCode(Context context) {
TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null) {
return extractMNC(telephonyManager.getSimOperator());
}
return "unknown";
}
代码示例来源:origin: yaozs/YzsLib
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";
代码示例来源:origin: org.infobip.mobile.messaging.api/infobip-mobile-messaging-android-sdk
public static String getSIMCoutryCode(Context context) {
TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null) {
return extractMCC(telephonyManager.getSimOperator());
}
return "unknown";
}
代码示例来源:origin: 0xm1nam0/RxCore
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";
代码示例来源:origin: hoangkien0705/Android-UtilCode
/**
* 获取Sim卡运营商名称
* <p>中国移动、如中国联通、中国电信</p>
*
* @return 移动网络运营商名称
*/
public static String getSimOperatorByMnc() {
TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
String operator = tm != null ? tm.getSimOperator() : null;
if (operator == null) return null;
switch (operator) {
case "46000":
case "46002":
case "46007":
return "中国移动";
case "46001":
return "中国联通";
case "46003":
return "中国电信";
default:
return operator;
}
}
代码示例来源:origin: 0xm1nam0/RxCore
/**
* 获取Sim卡运营商名称
* <p>中国移动、如中国联通、中国电信</p>
*
* @return 移动网络运营商名称
*/
public static String getSimOperatorByMnc() {
TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
String operator = tm != null ? tm.getSimOperator() : null;
if (operator == null) return null;
switch (operator) {
case "46000":
case "46002":
case "46007":
return "中国移动";
case "46001":
return "中国联通";
case "46003":
return "中国电信";
default:
return operator;
}
}
代码示例来源:origin: com.squareup.assertj/assertj-android
public TelephonyManagerAssert hasSimOperator(String operator) {
isNotNull();
String actualOperator = actual.getSimOperator();
assertThat(actualOperator) //
.overridingErrorMessage("Expected SIM operator <%s> but was <%s>.", operator,
actualOperator) //
.isEqualTo(operator);
return this;
}
代码示例来源:origin: braintree/braintree_android
.thenReturn(resolveInfo);
TelephonyManager telephonyManager = mock(TelephonyManager.class);
when(telephonyManager.getSimOperator()).thenReturn("12345");
Context context = spy(RuntimeEnvironment.application);
when(context.getPackageManager()).thenReturn(packageManager);
代码示例来源:origin: rumboalla/apkupdater
private AndroidCheckinProto getCheckinProto() {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return AndroidCheckinProto.newBuilder()
.setBuild(getBuildProto())
.setLastCheckinMsec(0)
.setCellOperator(tm.getNetworkOperator())
.setSimOperator(tm.getSimOperator())
.setRoaming("mobile-notroaming")
.setUserNumber(0)
.build()
;
}
内容来源于网络,如有侵权,请联系作者删除!