本文整理了Java中android.telephony.TelephonyManager.getNetworkOperator()
方法的一些代码示例,展示了TelephonyManager.getNetworkOperator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TelephonyManager.getNetworkOperator()
方法的具体详情如下:
包路径:android.telephony.TelephonyManager
类名称:TelephonyManager
方法名:getNetworkOperator
暂无
代码示例来源:origin: smuyyh/BookReader
/**
* 获取手机网络运营商类型
*
* @param context
* @return
*/
public static String getPhoneISP(Context context) {
if (context == null) {
return "";
}
TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String teleCompany = "";
String np = manager.getNetworkOperator();
if (np != null) {
if (np.equals(CMCC_ISP) || np.equals(CMCC2_ISP)) {
teleCompany = "中国移动";
} else if (np.startsWith(CU_ISP)) {
teleCompany = "中国联通";
} else if (np.startsWith(CT_ISP)) {
teleCompany = "中国电信";
}
}
return teleCompany;
}
代码示例来源:origin: ac-pm/Inspeckage
li.add(new FingerprintItem("TelephonyManager", "PhoneNumber", mTelephonyManager.getLine1Number(), mTelephonyManager.getLine1Number(), false));
li.add(new FingerprintItem("TelephonyManager", "SimSerial", mTelephonyManager.getSimSerialNumber(), mTelephonyManager.getSimSerialNumber(), false));
li.add(new FingerprintItem("TelephonyManager", "CarrierCode", mTelephonyManager.getNetworkOperator(), mTelephonyManager.getNetworkOperator(), false));
li.add(new FingerprintItem("TelephonyManager", "Carrier", mTelephonyManager.getNetworkOperatorName(), mTelephonyManager.getNetworkOperatorName(), false));
li.add(new FingerprintItem("TelephonyManager", "SimCountry", mTelephonyManager.getSimCountryIso(), mTelephonyManager.getSimCountryIso(), false));
代码示例来源:origin: square/assertj-android
public TelephonyManagerAssert hasNetworkOperator(String operator) {
isNotNull();
String actualOperator = actual.getNetworkOperator();
assertThat(actualOperator) //
.overridingErrorMessage("Expected network operator <%s> but was <%s>.", operator,
actualOperator) //
.isEqualTo(operator);
return this;
}
代码示例来源:origin: stackoverflow.com
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation cellLocation = (GsmCellLocation) telephonyManager
.getCellLocation();
// Cell Id, LAC
int cellid = cellLocation.getCid();
int lac = cellLocation.getLac();
// MCC
String MCC = telephonyManager.getNetworkOperator();
int mcc = Integer.parseInt(MCC.substring(0, 3));
// Operator name
String operatoprName = telephonyManager.getNetworkOperatorName();
代码示例来源:origin: wangdan/AisenWeiBo
location = (GsmCellLocation) mTelNet.getCellLocation();
if (location != null) {
String operator = mTelNet.getNetworkOperator();
int mcc = Integer.parseInt(operator.substring(0, 3));
int mnc = Integer.parseInt(operator.substring(3));
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
String tmp = _telManager.getNetworkOperator();
if (tmp.length() >= 3) {
_MobileCountryCode = tmp.substring(0, 3);
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldGiveNetworkOperator() {
shadowOf(telephonyManager).setNetworkOperator("SomeOperator");
assertEquals("SomeOperator", telephonyManager.getNetworkOperator());
}
代码示例来源:origin: GeekGhost/Ghost
/**
* 获取当前网络类型
*
* @param context
* @return
*/
public static String getMcnc(Context context) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String mcnc = tm.getNetworkOperator();
if (TextUtils.isEmpty(mcnc)) {
return "0";
} else {
return mcnc;
}
}
代码示例来源:origin: TongmingWu/Manga
public static String getNetworkOperator(Context context) {
TelephonyManager telephonyManager = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
return telephonyManager.getNetworkOperator();
}
代码示例来源:origin: microg/android_external_UnifiedNlpApi
private int getMcc() {
try {
return Integer.parseInt(telephonyManager.getNetworkOperator().substring(0, 3));
} catch (Exception e) {
return -1;
}
}
代码示例来源:origin: microg/android_external_UnifiedNlpApi
private int getMnc() {
try {
return Integer.parseInt(telephonyManager.getNetworkOperator().substring(3));
} catch (Exception e) {
return -1;
}
}
代码示例来源:origin: org.infobip.mobile.messaging.api/infobip-mobile-messaging-android-sdk
public static String getMobileCoutryCode(Context context) {
TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null) {
return extractMCC(telephonyManager.getNetworkOperator());
}
return "unknown";
}
代码示例来源:origin: stackoverflow.com
TelephonyManager tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String networkOperator = tel.getNetworkOperator();
String countryCode = tel.getNetworkCountryIso();
if (TextUtils.isEmpty(networkOperator) == false) {
int mcc = Integer.parseInt(networkOperator.substring(0, 3));
int mnc = Integer.parseInt(networkOperator.substring(3));
}
代码示例来源:origin: org.infobip.mobile.messaging.api/infobip-mobile-messaging-android-sdk
public static String getMobileNetworkCode(Context context) {
TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null) {
return extractMNC(telephonyManager.getNetworkOperator());
}
return "unknown";
}
代码示例来源:origin: com.squareup.assertj/assertj-android
public TelephonyManagerAssert hasNetworkOperator(String operator) {
isNotNull();
String actualOperator = actual.getNetworkOperator();
assertThat(actualOperator) //
.overridingErrorMessage("Expected network operator <%s> but was <%s>.", operator,
actualOperator) //
.isEqualTo(operator);
return this;
}
代码示例来源:origin: Unity-Technologies/unity-ads-android
public static String getNetworkOperator() {
if(ClientProperties.getApplicationContext() != null) {
TelephonyManager tm = (TelephonyManager)ClientProperties.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
return tm.getNetworkOperator();
}
return "";
}
代码示例来源:origin: adjust/android_sdk
public static String getMcc(Context context) {
try {
TelephonyManager tel = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String networkOperator = tel.getNetworkOperator();
if (TextUtils.isEmpty(networkOperator)) {
AdjustFactory.getLogger().warn("Couldn't receive networkOperator string to read MCC");
return null;
}
return networkOperator.substring(0, 3);
} catch (Exception ex) {
AdjustFactory.getLogger().warn("Couldn't return mcc");
return null;
}
}
代码示例来源:origin: adjust/android_sdk
public static String getMnc(Context context) {
try {
TelephonyManager tel = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String networkOperator = tel.getNetworkOperator();
if (TextUtils.isEmpty(networkOperator)) {
AdjustFactory.getLogger().warn("Couldn't receive networkOperator string to read MNC");
return null;
}
return networkOperator.substring(3);
} catch (Exception ex) {
AdjustFactory.getLogger().warn("Couldn't return mnc");
return null;
}
}
代码示例来源: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()
;
}
代码示例来源: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());
}
}
内容来源于网络,如有侵权,请联系作者删除!