本文整理了Java中android.telephony.TelephonyManager.getNetworkOperatorName()
方法的一些代码示例,展示了TelephonyManager.getNetworkOperatorName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TelephonyManager.getNetworkOperatorName()
方法的具体详情如下:
包路径:android.telephony.TelephonyManager
类名称:TelephonyManager
方法名:getNetworkOperatorName
暂无
代码示例来源:origin: stackoverflow.com
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
String carrierName = manager.getNetworkOperatorName();
代码示例来源:origin: CarGuo/GSYVideoPlayer
/**
* 获取移动网络运营商名称
* <p>如中国联通、中国移动、中国电信</p>
*
* @param context 上下文
* @return 移动网络运营商名称
*/
public static String getNetworkOperatorName(Context context) {
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
return tm != null ? tm.getNetworkOperatorName() : null;
}
代码示例来源:origin: stackoverflow.com
TelephonyManager telephonyManager = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE));
String operatorName = telephonyManager.getNetworkOperatorName();
代码示例来源:origin: smuyyh/BookReader
/**
* 获取移动网络运营商名称
* <p>如中国联通、中国移动、中国电信</p>
*
* @param context 上下文
* @return 移动网络运营商名称
*/
public static String getNetworkOperatorName(Context context) {
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
return tm != null ? tm.getNetworkOperatorName() : null;
}
代码示例来源:origin: facebook/facebook-android-sdk
/**
* Get and cache the carrier name since this won't change during the lifetime of the app.
* @return The carrier name
*/
private static void refreshCarrierName(Context appContext) {
if (carrierName.equals(noCarrierConstant)) {
try {
TelephonyManager telephonyManager =
((TelephonyManager) appContext.getSystemService(Context.TELEPHONY_SERVICE));
carrierName = telephonyManager.getNetworkOperatorName();
} catch (Exception e) {
}
}
}
代码示例来源:origin: square/assertj-android
public TelephonyManagerAssert hasNetworkOperatorName(String name) {
isNotNull();
String actualName = actual.getNetworkOperatorName();
assertThat(actualName) //
.overridingErrorMessage("Expected network operator name <%s> but was <%s>.", name,
actualName) //
.isEqualTo(name);
return this;
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldGiveNetworkOperatorName() {
shadowOf(telephonyManager).setNetworkOperatorName("SomeOperatorName");
assertEquals("SomeOperatorName", telephonyManager.getNetworkOperatorName());
}
代码示例来源:origin: aws-amplify/aws-sdk-android
private String getCarrier(final Context context) {
try {
TelephonyManager telephony = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
if (null != telephony.getNetworkOperatorName()
&& !telephony.getNetworkOperatorName().equals("")) {
return telephony.getNetworkOperatorName();
} else {
return "Unknown";
}
} catch (Exception ex) {
return "Unknown";
}
}
代码示例来源:origin: aws-amplify/aws-sdk-android
private String getCarrier(final Context context) {
try {
TelephonyManager telephony = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
if (null != telephony.getNetworkOperatorName()
&& !telephony.getNetworkOperatorName().equals("")) {
return telephony.getNetworkOperatorName();
} else {
return "Unknown";
}
} catch (Exception ex) {
return "Unknown";
}
}
代码示例来源:origin: stackoverflow.com
TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String networkOperator = tm.getNetworkOperatorName();
if("Android".equals(networkOperator)) {
// Emulator
}
else {
// Device
}
代码示例来源:origin: curtis2/SuperVideoPlayer
@SuppressLint("NewApi")
public static String getIdentifiers(Context ctx) {
StringBuilder sb = new StringBuilder();
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO)
sb.append(getPair("serial", Build.SERIAL));
else
sb.append(getPair("serial", "No Serial"));
sb.append(getPair("android_id", Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID)));
TelephonyManager tel = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
sb.append(getPair("sim_country_iso", tel.getSimCountryIso()));
sb.append(getPair("network_operator_name", tel.getNetworkOperatorName()));
sb.append(getPair("unique_id", Crypto.md5(sb.toString())));
ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
sb.append(getPair("network_type", cm.getActiveNetworkInfo() == null ? "-1" : String.valueOf(cm.getActiveNetworkInfo().getType())));
return sb.toString();
}
代码示例来源:origin: ac-pm/Inspeckage
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));
li.add(new FingerprintItem("TelephonyManager", "NetworkCountry", mTelephonyManager.getNetworkCountryIso(), mTelephonyManager.getNetworkCountryIso(), false));
代码示例来源:origin: stackoverflow.com
// Returns the alphabetic name of current registered operator
public String getServiceProvider() {
TelephonyManager manager = (TelephonyManager)
getSystemService(Context.TELEPHONY_SERVICE);
String carrierName = manager.getNetworkOperatorName(); // alphabetic name of current registered operator
return carrierName;
}
代码示例来源:origin: yaozs/YzsLib
/**
* 获取网络运营商名称
* <p>中国移动、如中国联通、中国电信</p>
*
* @param context 上下文
* @return 运营商名称
*/
public static String getNetworkOperatorName(Context context) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return tm != null ? tm.getNetworkOperatorName() : null;
}
代码示例来源:origin: org.infobip.mobile.messaging.api/infobip-mobile-messaging-android-sdk
public static String getMobileCarrierName(Context context) {
TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null) {
return telephonyManager.getNetworkOperatorName();
}
return "unknown";
}
代码示例来源:origin: com.squareup.assertj/assertj-android
public TelephonyManagerAssert hasNetworkOperatorName(String name) {
isNotNull();
String actualName = actual.getNetworkOperatorName();
assertThat(actualName) //
.overridingErrorMessage("Expected network operator name <%s> but was <%s>.", name,
actualName) //
.isEqualTo(name);
return this;
}
代码示例来源:origin: sunfusheng/Gank.IO
/**
* 获取网络运营商名称
* <p>中国移动、如中国联通、中国电信</p>
*
* @return 运营商名称
*/
public static String getNetworkOperatorName() {
TelephonyManager tm =
(TelephonyManager) AppUtil.getApp().getSystemService(Context.TELEPHONY_SERVICE);
return tm != null ? tm.getNetworkOperatorName() : null;
}
代码示例来源:origin: Countly/countly-sdk-android
public void testGetCarrier() {
final TelephonyManager mockTelephonyManager = mock(TelephonyManager.class);
when(mockTelephonyManager.getNetworkOperatorName()).thenReturn("Verizon");
final Context mockContext = mock(Context.class);
when(mockContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mockTelephonyManager);
assertEquals("Verizon", DeviceInfo.getCarrier(mockContext));
}
代码示例来源:origin: Countly/countly-sdk-android
public void testGetCarrier_nullNetOperator() {
final TelephonyManager mockTelephonyManager = mock(TelephonyManager.class);
when(mockTelephonyManager.getNetworkOperatorName()).thenReturn(null);
final Context mockContext = mock(Context.class);
when(mockContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mockTelephonyManager);
assertEquals("", DeviceInfo.getCarrier(mockContext));
}
代码示例来源:origin: Countly/countly-sdk-android
public void testGetCarrier_emptyNetOperator() {
final TelephonyManager mockTelephonyManager = mock(TelephonyManager.class);
when(mockTelephonyManager.getNetworkOperatorName()).thenReturn("");
final Context mockContext = mock(Context.class);
when(mockContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mockTelephonyManager);
assertEquals("", DeviceInfo.getCarrier(mockContext));
}
内容来源于网络,如有侵权,请联系作者删除!