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

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

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

TelephonyManager.getSimCountryIso介绍

暂无

代码示例

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

TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
  String countryCode = tm.getSimCountryIso();

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

TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String countryCode = tm.getSimCountryIso();

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

public String GetCountryZipCode(){
  String CountryID="";
  String CountryZipCode="";

  TelephonyManager manager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
  //getNetworkCountryIso
  CountryID= manager.getSimCountryIso().toUpperCase();
  String[] rl=this.getResources().getStringArray(R.array.CountryCodes);
  for(int i=0;i<rl.length;i++){
    String[] g=rl[i].split(",");
    if(g[1].trim().equals(CountryID.trim())){
      CountryZipCode=g[0];
      break;  
    }
  }
  return CountryZipCode;
}

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

/**
 * Get ISO 3166-1 alpha-2 country code for this device (or null if not available)
 * @param context Context reference to get the TelephonyManager instance from
 * @return country code or null
 */
public static String getUserCountry(Context context) {
  try {
    final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    final String simCountry = tm.getSimCountryIso();
    if (simCountry != null && simCountry.length() == 2) { // SIM country code is available
      return simCountry.toLowerCase(Locale.US);
    }
    else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) { // device is not 3G (would be unreliable)
      String networkCountry = tm.getNetworkCountryIso();
      if (networkCountry != null && networkCountry.length() == 2) { // network country code is available
        return networkCountry.toLowerCase(Locale.US);
      }
    }
  }
  catch (Exception e) { }
  return null;
}

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

public TelephonyManagerAssert hasSimCountryIso(String iso) {
 isNotNull();
 String actualIso = actual.getSimCountryIso();
 assertThat(actualIso) //
   .overridingErrorMessage("Expected SIM country ISO <%s> but was <%s>.", iso, actualIso) //
   .isEqualTo(iso);
 return this;
}

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

@Test
public void shouldGetSimIso() {
 assertThat(telephonyManager.getSimCountryIso()).isEmpty();
}

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

@Test
@Config(minSdk = N)
public void resetSimCountryIsos_shouldRetainDefaultState() {
 shadowOf(telephonyManager).resetSimCountryIsos();
 assertThat(telephonyManager.getSimCountryIso()).isEmpty();
}

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

@Test
@Config(minSdk = N)
public void shouldGetSimIosWhenSetUsingSlotNumber() {
 String expectedSimIso = "usa";
 int subId = 2;
 shadowOf(telephonyManager).setSimCountryIso(subId, expectedSimIso);
 assertThat(telephonyManager.getSimCountryIso(subId)).isEqualTo(expectedSimIso);
}

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

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

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

try {
  TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
  String countryCode = tm.getSimCountryIso();
  final PhoneNumber phoneNumber = phoneNumberUtil.parse(normalizedPhone, countryCode.toUpperCase());
  final String formattedPhoneNumber = phoneNumberUtil.format(phoneNumber, PhoneNumberFormat.E164).replaceAll("[^0-9]", "");

代码示例来源:origin: ac-pm/Inspeckage

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));
li.add(new FingerprintItem("TelephonyManager", "SimSerialNumber", mTelephonyManager.getSimSerialNumber(), mTelephonyManager.getSimSerialNumber(), false));

代码示例来源:origin: geniusgithub/AndroidDialer

/**
 * @return the country code of the SIM card currently inserted in the device.
 */
private String getSimBasedCountryIso() {
  return mTelephonyManager.getSimCountryIso();
}

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

String GetCountryZipCode(){
 String CountryID="";
 String CountryZipCode="";
 TelephonyManager manager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
    //getNetworkCountryIso
 CountryID= manager.getSimCountryIso().toUpperCase();
 String[] rl=this.getResources().getStringArray(R.array.CountryCodes);
 for(int i=0;i<rl.length;i++){
               String[] g=rl[i].split(",");
               if(g[1].trim().equals(CountryID.trim())){
                         CountryZipCode=g[0];break;  }
 }

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

String GetCountryZipCode(){
   String CountryID="";
   String CountryZipCode="";
   TelephonyManager manager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
      //getNetworkCountryIso
   CountryID= manager.getSimCountryIso().toUpperCase();
   String[] rl=this.getResources().getStringArray(R.array.CountryCodes);
   for(int i=0;i<rl.length;i++){
                 String[] g=rl[i].split(",");
                 if(g[1].trim().equals(CountryID.trim())){
                           CountryZipCode=g[0];break;  }
   }

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

String GetCountryZipCode(){
   String CountryID="";
   String CountryZipCode="";
   TelephonyManager manager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
      //getNetworkCountryIso
   CountryID= manager.getSimCountryIso().toUpperCase();
   String[] rl=this.getResources().getStringArray(R.array.CountryCodes);
   for(int i=0;i<rl.length;i++){
                 String[] g=rl[i].split(",");
                 if(g[1].trim().equals(CountryID.trim())){
                           CountryZipCode=g[0];break;  }
   }

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

String locale = context.getResources().getConfiguration().locale.getCountry(); 
// or if you are sure there is a SIM-card
TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String countryCode = tm.getSimCountryIso();
// or use country of current network (i.e. from 3G)
String countryCode = tm.getNetworkCountryIso()

代码示例来源:origin: mukeshsolanki/country-picker-android

public Country getCountryFromSIM() {
 TelephonyManager telephonyManager =
   (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
 if (telephonyManager != null
   && telephonyManager.getSimState() != TelephonyManager.SIM_STATE_ABSENT) {
  return getCountryByISO(telephonyManager.getSimCountryIso());
 }
 return null;
}

代码示例来源:origin: gpfduoduo/AirPlay-Receiver-on-Android

public static String getIdentifiers(Context ctx) {
 StringBuilder sb = new StringBuilder();
 sb.append(getPair("serial", Build.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())));
 return sb.toString();
}

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

相关文章