android.telephony.TelephonyManager.getSimOperatorName()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中android.telephony.TelephonyManager.getSimOperatorName()方法的一些代码示例,展示了TelephonyManager.getSimOperatorName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TelephonyManager.getSimOperatorName()方法的具体详情如下:
包路径:android.telephony.TelephonyManager
类名称:TelephonyManager
方法名:getSimOperatorName

TelephonyManager.getSimOperatorName介绍

暂无

代码示例

代码示例来源:origin: square/assertj-android

public TelephonyManagerAssert hasSimOperatorName(String name) {
 isNotNull();
 String actualName = actual.getSimOperatorName();
 assertThat(actualName) //
   .overridingErrorMessage("Expected SIM operator name <%s> but was <%s>.", name,
     actualName) //
   .isEqualTo(name);
 return this;
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldGiveSimOperatorName() {
 shadowOf(telephonyManager).setSimOperatorName("SomeSimOperatorName");
 assertEquals("SomeSimOperatorName", telephonyManager.getSimOperatorName());
}

代码示例来源:origin: GitPhoenix/KeyboardView

/**
 * 获取Sim卡运营商名称
 * <p>中国移动、如中国联通、中国电信</p>
 *
 * @param context 上下文
 * @return sim卡运营商名称
 */
public static String getSimOperatorName(Context context) {
  TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
  return tm != null ? tm.getSimOperatorName() : null;
}

代码示例来源:origin: org.infobip.mobile.messaging.api/infobip-mobile-messaging-android-sdk

public static String getSIMCarrierName(Context context) {
  TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
  if (telephonyManager != null) {
    return telephonyManager.getSimOperatorName();
  }
  return "unknown";
}

代码示例来源:origin: yaozs/YzsLib

/**
 * 获取Sim卡运营商名称
 * <p>中国移动、如中国联通、中国电信</p>
 *
 * @param context 上下文
 * @return sim卡运营商名称
 */
public static String getSimOperatorName(Context context) {
  TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
  return tm != null ? tm.getSimOperatorName() : null;
}

代码示例来源:origin: braintree/braintree_android

public static String getSimOperatorName(Context context) {
  try {
    return ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE))
        .getSimOperatorName();
  } catch (SecurityException e) {
    return null;
  }
}

代码示例来源:origin: huntermr/FastAndroid

public static String getOperatorName() {
  TelephonyManager telephonyManager = (TelephonyManager) BaseApplication.getInstance().getSystemService(TELEPHONY_SERVICE);
  if (telephonyManager == null) {
    return "OTHER";
  }
  return telephonyManager.getSimOperatorName();
}

代码示例来源:origin: hoangkien0705/Android-UtilCode

/**
 * 获取Sim卡运营商名称
 * <p>中国移动、如中国联通、中国电信</p>
 *
 * @return sim卡运营商名称
 */
public static String getSimOperatorName() {
  TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
  return tm != null ? tm.getSimOperatorName() : null;
}

代码示例来源:origin: 0xm1nam0/RxCore

/**
 * 获取Sim卡运营商名称
 * <p>中国移动、如中国联通、中国电信</p>
 *
 * @return sim卡运营商名称
 */
public static String getSimOperatorName() {
  TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
  return tm != null ? tm.getSimOperatorName() : null;
}

代码示例来源:origin: stackoverflow.com

TelephonyManager telephonyManager =((TelephonyManager) 
Context.getSystemService(Context.TELEPHONY_SERVICE));

// Network operator IDEA,AIRTEL...
String networkOperatorName = telephonyManager.getNetworkOperatorName();

// sim operator IDEA,AIRTEL,BSNL,MTNL...
String simOperatorName = telephonyManager.getSimOperatorName();

代码示例来源:origin: stackoverflow.com

//Here is snippet, hope it helps you!
TelephonyManager tManager = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);

// Get carrier name (Network Operator Name) 
String carrierName = tManager.getNetworkOperatorName();
String operatorName = tManager.getSimOperatorName(); //try this

// Get Phone model and manufacturer name 
String manufacturer = Build.MANUFACTURER;
String model = Build.MODEL;

代码示例来源:origin: stackoverflow.com

TelephonyManager telephonyManager =((TelephonyManager) Context.getSystemService(Context.TELEPHONY_SERVICE));
String operatorName = telephonyManager.getNetworkOperatorName();
similarly the sim operator can be retrieved by using:

String operatorName = telephonyManager.getSimOperatorName();

代码示例来源:origin: Null-Ouwenjie/zhizhihu

/**
 * 获取运营商名称
 *
 * @param cxt
 * @return
 */
public static String getProvider(Context cxt) {
  if (null == cxt)
    return "";
  String provider;
  TelephonyManager tm;
  tm = (TelephonyManager) cxt.getSystemService(Context.TELEPHONY_SERVICE);
  if (tm.getSimState() == TelephonyManager.SIM_STATE_READY) {// 有手机卡
    provider = tm.getSimOperatorName();
  } else { // 没有手机卡
    provider = "";
  }
  return provider;
}

代码示例来源:origin: com.squareup.assertj/assertj-android

public TelephonyManagerAssert hasSimOperatorName(String name) {
 isNotNull();
 String actualName = actual.getSimOperatorName();
 assertThat(actualName) //
   .overridingErrorMessage("Expected SIM operator name <%s> but was <%s>.", name,
     actualName) //
   .isEqualTo(name);
 return this;
}

代码示例来源: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: stackoverflow.com

TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
   String deviceID =telephonyManager.getDeviceId();
   String deviceID1 =telephonyManager.getSimSerialNumber();
   String deviceID2 =telephonyManager.getSimOperatorName();

代码示例来源:origin: stackoverflow.com

// Collecting device details
     TelephonyManager tm = (TelephonyManager) c
         .getSystemService(Context.TELEPHONY_SERVICE);
     String model = android.os.Build.MODEL;
     String brand = android.os.Build.BRAND;
     String id = tm.getDeviceId();
     String simSerial = tm.getSimSerialNumber();
     String simCountry = tm.getSimCountryIso();
     String simOperator = tm.getSimOperatorName();
     String networkCountry = tm.getNetworkCountryIso();

代码示例来源: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: 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());
     }
   }

相关文章