List of usage examples for java.lang String toLowerCase
public String toLowerCase(Locale locale)
From source file:Main.java
/** * 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//from w w w. ja v a2 s . c o m */ public static String getDeviceCountry(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; }
From source file:Main.java
private static Byte encodeUriScheme(String uri) { String lowerCaseUri = uri.toLowerCase(Locale.ENGLISH); for (int i = 0; i < URI_SCHEMES.size(); i++) { // get the key and value. int key = URI_SCHEMES.keyAt(i); String value = URI_SCHEMES.valueAt(i); if (lowerCaseUri.startsWith(value)) { return (byte) key; }/*from www . ja v a 2 s. co m*/ } return null; }